Adjust shutdown order to prevent potential deadlocks when one thread calls Shutdown, and another calls WaitForCompletion.