What is the registry key to terminate sessions on disconnect

Solution 1:

You do not need to edit the registry to do what you want to do, you need to change the Group Policy. Run GPEDIT.MSC and under Local Computer Policy navigate to Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections and change the settings under Configure keep-alive connection interval. For an even finer adjustment you might also want to look under Session Time Limits and change the settings under Set time limit for disconnected sessions.

Update:

After some more searching I found some Group Policy Management Scripts provided by Microsoft. They come in an installer package which puts all the scripts (and a read me file) in your Program Files folder in a folder called Microsoft Group Policy. There are many scripts for doing different things, and I am sure one of them will do what you want. Without doing any more research on the subject it seems like the script CreateEnvironmentFromXML is what you will want to use. Here is the download link.

Solution 2:

Under HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services, add these DWORD values:

MaxDisconnectionTime
MaxIdleTime

If set to 60000 (milliseconds), the time-outs will be one minute.

Full registry key file:

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services]
"MaxDisconnectionTime"=dword:0000EA60
"MaxIdleTime"=dword:0000EA60