Solved closing windows properly