public function stopWhenFilesChange(string $directoryPath, int $checkInterval = 30, int $stopDelay = 5): self
    {
        $checkInterval = 0 >= $checkInterval ? 1 : $checkInterval;
        $watcher       = new FileChangesWatcher($directoryPath);

        /** @psalm-suppress MixedTypeCoercion Incorrect amphp types */
        Loop::repeat(
            $checkInterval * 1000,
            function() use ($watcher, $stopDelay): \Generator
            {
                /** @var bool $changed */
                $changed = yield $watcher->compare();

                if (true === $changed)
                {
                    /** @var LoggerInterface $logger */
                    $logger = $this->getKernelContainerService('service_bus.logger');

                    $logger->info(
                        'Application files have been changed. Shut down after {delay} seconds',
                        ['delay' => $stopDelay]
                    );

                    $this->entryPoint->stop($stopDelay);
                }
            }
        );

        return $this;
    }