Made sure that Shutdown is called from the right thread