Shutdown cleanup

Here's my extended take on the shutdown cleanup.