Fix for crash on exit.