If you want a pure-Python solution to this, you'll have to wrap your script with a try/except clause:
import traceback
try:
... your script ...
except:
traceback.print_exc()
raw_input("Press Enter to close") # Python 2
input("Press Enter to close") # Python 3
This way the window will stay open, even when your code throws an exception. It will still close when Python cannot parse the script, i.e. when you have a syntax error. If you want to fix that too, I'd suggest a good IDE that allows you to develop in a more pleasant way (PyCharm and PyDev come to mind).