How to stop the python program halfway (without manually shutting down)

is there anything like, after running a python program, I will finish two python programs directly after running the other one? I hope you can give me some advice

.
Mar.07,2021

can I use threads?

Menu