code: def stop(self):
          
          if self._thread:
              self.signal.put("Stop")
              self._thread.join()
              if self._soc:
                  self._soc.shutdown()
                  self._soc.close()
              self._thread = None
docs: Stop thread.