diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index d7479925cb..35b67265c7 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6581,6 +6581,7 @@ threadRun(void *arg)
 				 * than coldly exiting with an error message.
 				 */
 				THREAD_BARRIER_WAIT(&barrier);
+				state[i].state = CSTATE_ABORTED;
 				goto done;
 			}
 		}
@@ -6647,6 +6648,7 @@ threadRun(void *arg)
 				if (sock < 0)
 				{
 					pg_log_error("invalid socket: %s", PQerrorMessage(st->con));
+					st->state = CSTATE_ABORTED;
 					goto done;
 				}
 
@@ -6708,6 +6710,7 @@ threadRun(void *arg)
 				}
 				/* must be something wrong */
 				pg_log_fatal("%s() failed: %m", SOCKET_WAIT_METHOD);
+				state[0].state = CSTATE_ABORTED;
 				goto done;
 			}
 		}
@@ -6733,6 +6736,7 @@ threadRun(void *arg)
 				if (sock < 0)
 				{
 					pg_log_error("invalid socket: %s", PQerrorMessage(st->con));
+					st->state = CSTATE_ABORTED;
 					goto done;
 				}
 
