/** * {@inheritdoc} */ public function end(string $data = '', float $timeout = 0) : \Generator { if (!$this->writable->isWritable()) { throw new UnwritableException('The stream is no longer writable.'); } try { $written = (yield from $this->writable->end($data, $timeout)); } finally { $this->readable->close(); } return $written; }