fixed crash when exit on Mac OS X