I am aware of the die() command in PHP which exits a script early.
die()
How can I do this in Python?
from sys import exit exit()
As a parameter you can pass an exit code, which will be returned to OS. Default is 0.