fixed shutdown bug