Session logout: force termination of application on Windows Terminal Server 2008 and higher

citrixwindows-server-2008windows-server-2012windows-terminal-services

In a pure Windows based Terminal Server Environment I am looking for ways to force the termination of an application after session logout/timeout.

With Citrix services I could use HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Citrix\wfshell\TWI to list all applications that should be terminated immediatly. But without Citrix I do not know if this is possible at all. I hope there is another registry entry for this purpose?

Background info: some misbehaving drivers are causing that the sessions will stay open after logout for longer periods of time. If we could register the apps that can be terminated safely the cleanup process will free the resources for the sessions much quicker. In our Citrix Environment this had tremendous impact thus we are looking for a solution for our pure Windows Environment too.

Thanks!

Best Answer

You might be able to fix this by setting the AutoEndTasks registry value to "1" (REG_SZ).

The default is "0":

Processes do not end automatically. The system waits until the process ends, and, if the process takes more time than the value of the HungAppTimeout entry, the End Task dialog box appears, stating that the application cannot respond to the End Task request.

You can tweak the timeouts by configuring the following registry values:

As @Frankenstein points out, AutoEndTasks could potentially terminate programs, not saving changes to open documents, two points are worth taking into account:

  • This would likely only be a (potential) issue if users are logging off full desktop sessions, without saving their work. For seamless applications, users cannot easily trigger the logoff process, without actually closing their remote applications.
  • Even running the (minor, in my opinion) risk of users losing changes in open documents, consider the administrative implications, of not terminating applications, that do not respond to the close signal. Scheduled maintenance that requires reboot (e.g. patching), can be stalled by a user that haven't saved his Word document. Administrator initiated session logoffs may not complete etc.

From an administrative standpoint, I think AutoEndTasks is necessary. If you want to buy users more time, you can configure the WaitToKillAppTimeout registry value.