diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index de2d4ee582..8795cb9a9c 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -993,7 +993,12 @@ XLogInsertRecord(XLogRecData *rdata,
 
 	/* cross-check on whether we should be here or not */
 	if (!XLogInsertAllowed())
-		elog(ERROR, "cannot make new WAL entries during recovery");
+	{
+		if(RecoveryInProgress())
+			elog(ERROR, "cannot make new WAL entries during recovery");
+		else
+			elog(ERROR, "cannot make new WAL entries during shutdown");
+	}
 
 	/*----------
 	 *
