def METHOD_NAME(self):
    if not self.context_model.is_modified():
        return True
    if self.filepath():
        filename = os.path.basename(self.filepath())
        id_str = "context %r" % filename
        title = "Close %s" % filename
    else:
        id_str = "the context"
        title = "Close context"
    if self.context_model.is_stale():
        ret = QtWidgets.QMessageBox.warning(
            self,
            title,
            "%s is pending a resolve.\n"
            "Close and discard changes?\n"
            "If you close, your changes will be lost."
            % id_str.capitalize(),
            QtWidgets.QMessageBox.Discard,
            QtWidgets.QMessageBox.Cancel)
        return (ret == QtWidgets.QMessageBox.Discard)
    else:
        ret = QtWidgets.QMessageBox.warning(
            self,
            title,
            "Save the changes to %s before closing?\n"
            "If you don't save the context, your changes will be lost."
            % id_str,
            buttons=(
                QtWidgets.QMessageBox.Save
                | QtWidgets.QMessageBox.Discard
                | QtWidgets.QMessageBox.Cancel
            )
        )
        if ret == QtWidgets.QMessageBox.Save:
            if self.is_saveable():
                self._save_context()
                return True
            else:
                assert self.is_save_as_able()
                return self._save_context_as()
        else:
            return (ret == QtWidgets.QMessageBox.Discard)
    raise RuntimeError("Should never get here")  # NOSONAR