fix shutdown bug