Better window destruction on windows and some other cleanup