The FreeConsole function detaches the calling process from its console.
BOOL FreeConsole(VOID)
This function has no parameters.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If other processes share the console, the console is not destroyed, but the calling process cannot refer to it.
A process can use FreeConsole to detach itself from its current console, and then it can call the AllocConsole function to create a new console.