Fixed error on exit in windows