Fixed a crash whenever user quit the application on Mac OSX