Handle shutdown.