Wait for shutdown