diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index a2846c4..07a7679 100644
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
*************** ShutdownXLOG(int code, Datum arg)
*** 7948,7957 ****
  	ShutdownCommitTs();
  	ShutdownSUBTRANS();
  	ShutdownMultiXact();
- 
- 	/* Don't be chatty in standalone mode */
- 	ereport(IsPostmasterEnvironment ? LOG : NOTICE,
- 			(errmsg("database system is shut down")));
  }
  
  /*
--- 7948,7953 ----
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index b7bab56..603a256 100644
*** a/src/backend/utils/init/miscinit.c
--- b/src/backend/utils/init/miscinit.c
*************** UnlinkLockFiles(int status, Datum arg)
*** 724,729 ****
--- 724,740 ----
  	}
  	/* Since we're about to exit, no need to reclaim storage */
  	lock_files = NIL;
+ 
+ 	/*
+ 	 * Lock file removal should always be the last externally visible action
+ 	 * of a postmaster or standalone backend, while we won't come here at all
+ 	 * when exiting postmaster child processes.  Therefore, this is a good
+ 	 * place to log completion of shutdown.  We could alternatively teach
+ 	 * proc_exit() to do it, but that seems uglier.  In a standalone backend,
+ 	 * use NOTICE elevel to be less chatty.
+ 	 */
+ 	ereport(IsPostmasterEnvironment ? LOG : NOTICE,
+ 			(errmsg("database system is shut down")));
  }
  
  /*
