diff --git a/src/scripting.c b/src/scripting.c
index 8ab603a2f..07719f958 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -1650,6 +1650,12 @@ int ldbRemoveChild(pid_t pid) {
     return 0;
 }
 
+/* Return the number of children we still did not received termination
+ * acknowledge via wait() in the parent process. */
+int ldbPendingChildren(void) {
+    return listLength(ldb.children);
+}
+
 /* Kill all the forked sessions. */
 void ldbKillForkedSessions(void) {
     listIter li;
diff --git a/src/server.c b/src/server.c
index e6844c785..a9e994362 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1186,7 +1186,9 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
     }
 
     /* Check if a background saving or AOF rewrite in progress terminated. */
-    if (server.rdb_child_pid != -1 || server.aof_child_pid != -1) {
+    if (server.rdb_child_pid != -1 || server.aof_child_pid != -1 ||
+        ldbPendingChildren())
+    {
         int statloc;
         pid_t pid;
 
diff --git a/src/server.h b/src/server.h
index 96004fa1f..0c5fcdb55 100644
--- a/src/server.h
+++ b/src/server.h
@@ -1473,6 +1473,7 @@ int redis_check_rdb_main(char **argv, int argc);
 void scriptingInit(int setup);
 int ldbRemoveChild(pid_t pid);
 void ldbKillForkedSessions(void);
+int ldbPendingChildren(void);
 
 /* Blocked clients */
 void processUnblockedClients(void);