def close(self) -> None: self._finalize() # We cannot have a reference to `self` because we must avoid reference cycles here (see weakref.finalize documentation).