function close() {
        if (isset($this->res)) {
            $this->stdout->close();
            fclose($this->pipes[0]);
            $status = $this->status();
            $exit = $status['running'] ? proc_close($this->res) : $status['exitcode'];
            unset($this->res, $this->pipes, $this->stdout);
            return $exit;
        }
        return null;
    }