Fix rare deadlock when an error message would pop on exit