Fix shutdown when using a single thread.