diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in
index 2ebdcb5702f7d784ea6d138001a3c1316e596401..7722ace52700362f5cd9e36fe663cbe3d552159d 100644
--- a/slurm/slurm.h.in
+++ b/slurm/slurm.h.in
@@ -382,6 +382,8 @@ enum select_jobdata_type {
 				   * start_loc[SYSTEM_DIMENSIONS] */
 	SELECT_JOBDATA_USER_NAME, /* data-> char * user_name */
 	SELECT_JOBDATA_CONFIRMED, /* data-> uint8_t ALPS reservation confirmed */
+	SELECT_JOBDATA_CLEANING, /* data-> uint16_t if the job is in
+				  * cleaning state or not. */
 };
 
 enum select_nodedata_type {
diff --git a/src/plugins/select/bluegene/bg_job_info.c b/src/plugins/select/bluegene/bg_job_info.c
index 925f85b27e156480684b3b24f628e90a5e2d99ab..0915a567ecabc02a02de510c4f133d50cb78d8b5 100644
--- a/src/plugins/select/bluegene/bg_job_info.c
+++ b/src/plugins/select/bluegene/bg_job_info.c
@@ -370,6 +370,13 @@ extern int get_select_jobinfo(select_jobinfo_t *jobinfo,
 		else
 			*tmp_char = xstrdup(jobinfo->user_name);
 		break;
+	case SELECT_JOBDATA_CLEANING:
+		/* In the case of Cleaning it means we have a block_ptr. */
+		if (jobinfo->bg_record)
+			*uint16 = 1;
+		else
+			*uint16 = 0;
+		break;
 	default:
 		debug2("get_jobinfo data_type %d invalid",
 		       data_type);
diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c
index e77e9cb618c4ec9dc5f79bbc143a22d7780ed7cc..281685e4a1e725885d2ebf20ef4ace8e7c84daf9 100644
--- a/src/slurmctld/step_mgr.c
+++ b/src/slurmctld/step_mgr.c
@@ -241,6 +241,15 @@ extern void delete_step_records (struct job_record *job_ptr)
 
 	last_job_update = time(NULL);
 	while ((step_ptr = (struct step_record *) list_next (step_iterator))) {
+		uint16_t cleaning = 0;
+		select_g_select_jobinfo_get(job_ptr->select_jobinfo,
+					    SELECT_JOBDATA_CLEANING,
+					    &cleaning);
+		if (cleaning)
+			continue;      /* Step hasn't finished yet it
+					* will be removed when it
+					* does complete. */
+
 		_internal_step_complete(job_ptr, step_ptr, true);
 		list_remove (step_iterator);
 		_free_step_rec(step_ptr);