Program now exits gracefully if there is an error.