Fixed a crash on exit on Windows.