'Close port'

def close(self):

    self.is_open = False
    if self._socket:
        try:
            self._socket.shutdown(socket.SHUT_RDWR)
            self._socket.close()
        except:
            pass
    if self._thread:
        self._thread.join(7)
        self._thread = None
        time.sleep(0.3)
    self._socket = None
