Closing a Console

A process can use the FreeConsole function to detach itself from its console. If other processes share the console, the console is not destroyed, but the process that called FreeConsole cannot refer to it. After calling FreeConsole, the process can use AllocConsole to create a new console or AttachConsole to attach to another console.

A console is closed when the last process attached to it terminates or calls FreeConsole.