def METHOD_NAME(self):
    """Close this file, saving the lockfile over the original.
    Note: If this method fails, it will attempt to delete the lockfile.
        However, it is not guaranteed to do so (e.g. if a filesystem
        becomes suddenly read-only), which will prevent future writes to
        this file until the lockfile is removed manually.
    Raises:
      OSError: if the original file could not be overwritten. The
        lock file is still closed, so further attempts to write to the same
        file object will raise ValueError.
    """
    if self._closed:
        return
    self._file.flush()
    os.fsync(self._file.fileno())
    self._file.METHOD_NAME()
    try:
        if getattr(os, "replace", None) is not None:
            os.replace(self._lockfilename, self._filename)
        else:
            if sys.platform != "win32":
                os.rename(self._lockfilename, self._filename)
            else:
                # Windows versions prior to Vista don't support atomic
                # renames
                _fancy_rename(self._lockfilename, self._filename)
    finally:
        self.abort()