fixed shutdown race condition