Use sys.exit(), plain exit() is only for use in interactive Python shell.