code: def close(self):
          
          try:
              if not self._closed and not self._owned:
                  self._dispose()
          finally:
              self.detach()
docs: Close this object and do any required clean-up actions.