Correctly delete window