fix regex for exiting Mathematica