Have window close when not needed