Made the thread block when calling shutdown until the main thread has
shutdown.