win32console.FreeConsole

FreeConsole()

Detaches process from its current console