Fix crash when quiting application.