Use sys.exit() instead of exit().