Programatically closing a window.