Yet another attempt at a completely clean shutdown.