code: def close(self):
          
          if (self.__ser is not None):
              self.__ser.close()
          if (self.__tcpClientSocket is not None):
              self.__stoplistening = True
              self.__tcpClientSocket.shutdown(socket.SHUT_RDWR)
              self.__tcpClientSocket.close()
          self.__connected = False
docs: Closes Serial port, or TCP-Socket connection