terminate program when it gets a few number of errors in a row