public function stop(int $delay = 10): void
    {
        $delay = 0 >= $delay ? 1 : $delay;

        /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
        Loop::defer(
            function() use ($delay): \Generator
            {
                yield $this->transport->stop();

                $this->logger->info('Handler will stop after {duration} seconds', ['duration' => $delay]);

                /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
                Loop::delay(
                    $delay * 1000,
                    function(): void
                    {
                        $this->logger->info('The event loop has been stopped');

                        Loop::stop();
                    }
                );
            }
        );
    }