fix crash on quitting application