def doStop(self):
        """
        Make sure stopProtocol is called.

        This will be called by the port, users should not call it.
        """
        assert self.numPorts > 0
        self.numPorts = self.numPorts - 1
        self.transport = None
        if not self.numPorts:
            if self.noisy:
                log.msg("Stopping protocol %s" % self)
            self.stopProtocol()

        Make sure stopProtocol is called.

        This will be called by the port, users should not call it.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/protocol.py