You put program code in a loop and designate one key to break out of loop:
# this is an example of your program:
print "My program! Really!"
choice = raw_input("Enter r (repeat) or q (quit): ")
if 'q' in choice:
break # exits the while loop, any other key repeats loop
Here is another example how to do this, as suggested by cscgal ...
# save this code as endless.py
password = raw_input("I am running almost endlessly unless you enter the secret password: ")
if 'q' in password:
raise SystemExit, "I am quitting now ..."
Notice how the ultimate escape has been accomplished.