public function stop($timeout = 1000)
    {
        $timeout = microtime(true) + ($timeout * 1000);

        if ($this->isRunning()) {
            proc_terminate($this->proc);
        }
        while ($this->isRunning() && microtime(true) < $timeout) {
            usleep(1000);
        }

        $this->readOutput();
        $this->readError();

        return $this;
    }