How can I stop my python code in the last line

Hi everyone

I need help on a task that I run every hour, for some reason when it finishes all the steps, I still see the CPU time processing running and I am in the tarpit every day. On average this process ends in 3 minutes.

I want to add a line to my code to force shutdown.

I already tried close() and exit().

Any suggestions for solving this

Your code will stop after the last line. You do not need to do anything.