fix crash on quit