Exit gracefully on error