diff --git a/redis.c b/redis.c
index fed633cf0..b95eb4556 100644
--- a/redis.c
+++ b/redis.c
@@ -8738,11 +8738,12 @@ static void stopAppendOnly(void) {
     if (server.bgsavechildpid != -1) {
         int statloc;
 
-        kill(server.bgsavechildpid,SIGKILL);
-        wait3(&statloc,0,NULL);
+        if (kill(server.bgsavechildpid,SIGKILL) != -1)
+            wait3(&statloc,0,NULL);
         /* reset the buffer accumulating changes while the child saves */
         sdsfree(server.bgrewritebuf);
         server.bgrewritebuf = sdsempty();
+        server.bgsavechildpid = -1;
     }
 }