fixed shutdown routine