Use Bash -e shell option instead of many exits

The result is the same, but this removes unnecessary code and avoids forgetting to add an exit command to a line.