docs: def close(self):
          '''
          Routines to handle any cleanup before the instance shuts down.
          Sockets and filehandles should be closed explicitly, to prevent
          leaks.
          '''
          if self._closing:
              return
          self._closing = True
          for stream in self.streams:
              stream.close()
          self.streams.clear()
          if hasattr(self.sock, 'close'):
              self.sock.close()