'Stop the background thread and clear registered resources.'

def stop(self, timeout=None):

    from .connection import Client
    with self._lock:
        if (self._address is not None):
            c = Client(self._address, authkey=process.current_process().authkey)
            c.send(None)
            c.close()
            self._thread.join(timeout)
            if self._thread.is_alive():
                util.sub_warning('_ResourceSharer    thread    did    not    stop    when    asked')
            self._listener.close()
            self._thread = None
            self._address = None
            self._listener = None
            for (key, (send, close)) in self._cache.items():
                close()
            self._cache.clear()
