factored Shutdown out of Main
more restructuring