diff --git a/src/plugins/job_container/tmpfs/job_container_tmpfs.c b/src/plugins/job_container/tmpfs/job_container_tmpfs.c
index 2680413a661ae5d37dbad9889496ed4f6214c773..96f98ce72b32d085897b4ebce6770ef2085edc6d 100644
--- a/src/plugins/job_container/tmpfs/job_container_tmpfs.c
+++ b/src/plugins/job_container/tmpfs/job_container_tmpfs.c
@@ -164,6 +164,10 @@ extern int fini(void)
 		error("%s: Configuration not loaded", __func__);
 		return SLURM_ERROR;
 	}
+	if (step_ns_fd != -1) {
+		close(step_ns_fd);
+		step_ns_fd = -1;
+	}
 	if (umount2(jc_conf->basepath, MNT_DETACH)) {
 		error("%s: umount2: %s failed: %s",
 		      __func__, jc_conf->basepath, strerror(errno));
@@ -171,11 +175,6 @@ extern int fini(void)
 	}
 	free_jc_conf();
 
-	if (step_ns_fd != -1) {
-		close(step_ns_fd);
-		step_ns_fd = -1;
-	}
-
 	return rc;
 }