Trying to fix crash on exit