Fix #939

It should not crash when you try to close the console on windows anymore
aswell.