fix shutdown race