exit when encountering error