Fixed crash on exit under windows