Terraform - graceful shutdown on job cancellation

Hi, I’m looking to find a solution to allow a pipeline to run with terraform with runners in k8s to allow for graceful termination on cancel.

Now I think the containers are starting and overwriting and CMD or ENTRYPOINT I try to set up to get around a quick SIGKILL and ending of the terraform job.