function stopWorker(\CharlotteDunois\Phoebe\Worker $worker) {
        if($worker->isRunning()) {
            try {
                $message = new \CharlotteDunois\Phoebe\Message('internal-worker-exit', null);
                $this->sendMessageToWorker($worker, $message);
            } catch (\RuntimeException $e) {
                /* Continue regardless of error */
            }
            
            $this->checkWorkerShutdown($worker);
        } else {
            $this->messenger->removeWorkerSocket($worker);
            $this->emit('exitWorker', $worker);
        }
        
        $this->removeWorker($worker);
    }