Now can gracefully close a window