Fixed bugs closing windows