Refactoring app close, frame, doc save_on_close, save_on_exit functions.