Index: win32ss/user/winsrv/consrv/handle.c
===================================================================
--- win32ss/user/winsrv/consrv/handle.c	(revision 62685)
+++ win32ss/user/winsrv/consrv/handle.c	(working copy)
@@ -663,6 +663,18 @@
         /* Update the internal info of the terminal */
         TermRefreshInternalInfo(Console);
 
+        /*
+         * Check if there is only one process still attached to the console,
+         * and that the console should send a control event in this case.
+         */
+        if ((Console->ProcessList.Flink != (PLIST_ENTRY)&Console->ProcessList)
+            && (Console->ProcessList.Flink->Flink == (PLIST_ENTRY)&Console->ProcessList)
+            && Console->NotifyLastClose)
+        {
+            /* Notify the process that it's the only process on the console */
+            ConDrvConsoleProcessCtrlEvent(Console, 0, CTRL_LAST_EVENT);
+        }
+
         /* Release the console */
         DPRINT("ConSrvRemoveConsole - Decrement Console->ReferenceCount = %lu\n", Console->ReferenceCount);
         ConDrvReleaseConsole(Console, TRUE);
Index: win32ss/user/winsrv/consrv/console.c
===================================================================
--- win32ss/user/winsrv/consrv/console.c	(revision 62685)
+++ win32ss/user/winsrv/consrv/console.c	(working copy)
@@ -638,8 +638,21 @@
 
 CSR_API(SrvConsoleNotifyLastClose)
 {
-    DPRINT1("%s not yet implemented\n", __FUNCTION__);
-    return STATUS_NOT_IMPLEMENTED;
+    NTSTATUS Status;
+    PCONSOLE Console;
+
+    Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
+    if (!NT_SUCCESS(Status)) return Status;
+
+    if (!Console->NotifyLastClose)
+    {
+        Console->NotifyLastClose = TRUE;
+        Status = STATUS_SUCCESS;
+    }
+    else Status = STATUS_ACCESS_DENIED;
+
+    ConSrvReleaseConsole(Console, TRUE);
+    return Status;
 }
 
 
Index: win32ss/user/winsrv/consrv/include/conio.h
===================================================================
--- win32ss/user/winsrv/consrv/include/conio.h	(revision 62685)
+++ win32ss/user/winsrv/consrv/include/conio.h	(working copy)
@@ -327,6 +327,7 @@
 
     COORD   ConsoleSize;                    /* The current size of the console, for text-mode only */
     BOOLEAN FixedSize;                      /* TRUE if the console is of fixed size */
+    BOOLEAN NotifyLastClose;                /* TRUE if the console should send a control event when a process detaches, and only one process is still attached to it */
 
     COLORREF Colors[16];                    /* Colour palette */
 
