Exit when there a failure in queries. Fixes #297.