'Called as the GUI is about to finish any interaction with the user
Returns non zero if we are allowed to stop interacting'

def GUIAboutToFinishInteract(self):

    if (self.oldForeground is not None):
        try:
            win32ui.GetMainFrame().EnableWindow(self.oldFrameEnableState)
            self.oldForeground.EnableWindow(1)
        except win32ui.error:
            pass
    if (not self.inForcedGUI):
        return 1
    for template in win32ui.GetApp().GetDocTemplateList():
        for doc in template.GetDocumentList():
            if (not doc.SaveModified()):
                return 0
    if self.get_option(OPT_HIDE):
        frame = win32ui.GetMainFrame()
        frame.ShowWindow(win32con.SW_HIDE)
    return 1
