Fixed handling window destruction