fix shutdown loop