Fix crash when quitting MacOSX