Attempted fix for shutdown race condition