GitHub #167: Test for unsaved changes before closing a window or the patch