public function close() { if ($this->out !== null) { $this->out->removeAllListeners(); } if ($this->in !== null) { $this->in->removeAllListeners(); } if ($this->err !== null) { $this->err->removeAllListeners(); } $this->process->removeAllListeners(); if ($this->process->isRunning()) { $this->process->terminate(); } }