code: def disconnect(self, driver):
          
          self.log("TELNETCONSOLE disconnect")
          try:
              while self.device.mode != 'global':
                  self.device.send('exit', timeout=10)
          except OSError:
              self.log("TELNETCONSOLE already disconnected")
          except pexpect.TIMEOUT:
              self.log("TELNETCONSOLE unable to get the root prompt")
  
          try:
              self.device.ctrl.send(chr(4))
          except OSError:
              self.log("TELNETCONSOLE already disconnected")
docs: Disconnect from the console.