fixed a freeze on program exit bug for windows