Handle the closing of the GUI nicer so local changes are discarded