Rework shutdown manager

for #49