cleanup code in window