fixed bug where window was staying open