If you have NOT already saved your current file, attempting to close will give you a prompt that "This has not been saved yet". But if you select "Save" and then do so, the program does NOT exit, which is the original intention. It does exit when you click "Save" if the file has been saved previously. So the unsaved behavior is unintended and inconsistent.
This patch makes is so clicking "Save" on the exit dialog will let you save and will exit if successful. Note that clicking the dialog "save" but then clicking "Cancel" in the File Browser will not exit. It will only exit if you do actually save.