Fix shutdown deadlock.