shutdown refactoring