public function kill($signal = SIGTERM)
    {
        if (!$this->isAlive()) {
            return false;
        }

        if (!proc_terminate($this->resource, $signal)) {
            return false;
        }

        $this->setStreamBlocking();

        while ($this->isAlive()) {
            usleep(50000);
        }

        $this->cleanup();
        return true;
    }