Changed to use sys.exit() as appropriate.