public function terminate($status = 0)
    {
        $this->working = false;

        // First we will terminate all child supervisors so they will gracefully scale
        // down to zero. We'll also grab the longest expiration times of any of the
        // active supervisors so we know the maximum amount of time to wait here.
        $longest = app(SupervisorRepository::class)
            ->longestActiveTimeout();

        $this->supervisors->each->terminate();

        // We will go ahead and remove this master supervisor's record from storage so
        // another master supervisor could get started in its place without waiting
        // for it to really finish terminating all of its underlying supervisors.
        app(MasterSupervisorRepository::class)
                    ->forget($this->name);

        $startedTerminating = Chronos::now();

        // Here we will wait until all of the child supervisors finish terminating and
        // then exit the process. We will keep track of a timeout value so that the
        // process does not get stuck in an infinite loop here waiting for these.
        while (count($this->supervisors->filter->isRunning())) {
            if (Chronos::now()->subSeconds($longest)
                        ->gte($startedTerminating)) {
                break;
            }

            sleep(1);
        }

        if (config('horizon.fast_termination')) {
            app(CacheFactory::class)->forget('horizon:terminate:wait');
        }

        $this->exit($status);
    }