/** * Finalize the coroutine. * * This method is invoked after the coroutine is popped from the call stack. * * @param StrandInterface $strand The strand that is executing the coroutine. */ public function finalize(StrandInterface $strand) { foreach ($this->substrands as $strand) { $strand->removeListener('exit', [$this, 'onStrandExit']); } }