diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index d67f9e7bb1cf1c06722386a8407839b226e56102..ff3229298c2e670e8bce986dfb39b041e9bcb039 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -1542,6 +1542,10 @@ void flushLocalEventsBuf(Capability *cap)
 // Used during forkProcess.
 void flushAllCapsEventsBufs()
 {
+    if (!event_log_writer) {
+        return;
+    }
+
     ACQUIRE_LOCK(&eventBufMutex);
     printAndClearEventBuf(&eventBuf);
     RELEASE_LOCK(&eventBufMutex);
@@ -1554,6 +1558,10 @@ void flushAllCapsEventsBufs()
 
 void flushEventLog(Capability **cap USED_IF_THREADS)
 {
+    if (!event_log_writer) {
+        return;
+    }
+
     ACQUIRE_LOCK(&eventBufMutex);
     printAndClearEventBuf(&eventBuf);
     RELEASE_LOCK(&eventBufMutex);