fix a cleanup segfault in case there is no intialized socket in the worker_thread