In Python, you can terminate a script by using the exit() function from the sys module.
There are several ways to stop a Python script from running: