created functionality for destroying windows