Prevent a crash on exit