xxxxxxxxxx
# Do stuff
stop = input("Would you like to stop the program? ")
if stop == "y":
exit()
else:
# do stuff
xxxxxxxxxx
import sys
print("Executing some code...")
# Manually stopping the program execution
sys.exit()
# The code below won't be executed
print("This code won't be executed.")