public function stop() : \Generator
{
try {
switch ($this->state) {
case self::STOPPED:
case self::STOPPING:
return;
case self::STARTED:
break;
}
$this->state = self::STOPPING;
yield from $this->doStop();
} catch (\Throwable $uncaught) {
$this->exitCode = 1;
$this->logger->critical($uncaught);
} finally {
static::exit();
}
}