fix crash on close