public function close()
    {
        $this->stop(0);

        if (is_resource($this->proc)) {
            proc_close($this->proc);
        }

        foreach ($this->pipes as $pipe) {
            if (is_resource($pipe)) {
                fclose($pipe);
            }
        }
    }