Added exit-if-failed function.