Importing sys will not be enough to make exit
live in the global scope.
You either need to do
from sys import exit
exit()
or
import sys
sys.exit()
Note that, as you are also using argv, in the first case you should do from sys import argv,exit