fix crash when shutdown app