Minor changes to shutdown logic.