examples/BatchEmailJob.php
protected function shutdown()
    {
        // Indicate to our main loop that we should stop processing additonal messages
        $this->shutdown = true;
        
        // Get a list of all the messages that have not yet been handled
        $this->args['messages'] = array_filter($this->messages, function($message) {
            if (!isset($message['sent']) || $message['sent'] === false) {
                return $message;
            }
        });

        $redis = new Redis;
        $client = new Client($redis);

        // Push the unfinished jobs back onto the priority queue with a priority of 100 
        // So they get processed as soon as possible.
        $client->push(static::class, $this->args, 1, 100);

        // Indicate that we've handled SIGTERM, and are ready to shut down
        return true;
    }
protected function shutdown()
    {
        // Indicate to our main loop that we should stop processing additonal messages
        $this->shutdown = true;
        
        // Get a list of all the messages that have not yet been handled
        $this->args['messages'] = array_filter($this->messages, function($message) {
            if (!isset($message['sent']) || $message['sent'] === false) {
                return $message;
            }
        });

        $redis = new Redis;
        $client = new Client($redis);

        // Push the unfinished jobs back onto the priority queue with a priority of 100 
        // So they get processed as soon as possible.
        $client->push(static::class, $this->args, 1, 100);

        // Indicate that we've handled SIGTERM, and are ready to shut down
        return true;
    }
Register a shutdown handler
@return bool