fixed a bug that causes crash when application is exited on Windows