diff --git a/NEWS b/NEWS
index f0228b9c751cca5c6661c2a00072c9dcbff44f3d..cf5cb0d52fd5bc6c2993f42c116bbb8bf787eb25 100644
--- a/NEWS
+++ b/NEWS
@@ -439,6 +439,7 @@ documents those changes that are of interest to users and administrators.
  -- Fix potential of slurmstepd segfaulting when the extern step fails to start.
  -- Allow nodes state to be updated between FAIL and DRAIN.
  -- Avoid registering a job'd credential multiple times.
+ -- Fix sbatch --wait to stop waiting after job is gone from memory.
 
 * Changes in Slurm 17.02.9
 ==========================
diff --git a/src/sbatch/sbatch.c b/src/sbatch/sbatch.c
index 57846baa85f0e179018fe79da1a2553fd2dd18c8..6e37b8511ffd18f28dd87fe34843b2408a1c3055 100644
--- a/src/sbatch/sbatch.c
+++ b/src/sbatch/sbatch.c
@@ -390,7 +390,12 @@ static int _job_wait(uint32_t job_id)
 				}
 			}
 			slurm_free_job_info_msg(resp);
-		} else if (rc == ESLURM_INVALID_JOB_ID) {
+		} else if ((rc == ESLURM_INVALID_JOB_ID) ||
+			   (errno == ESLURM_INVALID_JOB_ID)) {
+			/*
+			 * 17.11 returns the error code in rc (and errno). The
+			 * check for errno isn't needed in 17.11.
+			 */
 			error("Job %u no longer found and exit code not found",
 			      job_id);
 		} else {