Fix crash when quit