I want my worker to stop polling and executing tasks when the process is being terminated (Java client)

In a PreDestroy block within your application, call the shutdown() method on the TaskRunnerConfigurer instance that you have created to facilitate a graceful shutdown of your worker in case the process is being terminated.