fixed shutdown bugs