You may notice when troubleshooting long logoff times or hung logoffs, killing the EmPShost.exe process resolves the issue.
This process is installed by the Environment Manager Agent installer and is a required process for PowerShell actions and conditions in your configuration.
Once the custom script is executed the Environment Manager Agent will wait for the script to complete. If for a reason the script does not complete, this can hang logoff as the agent is still waiting for the response and to then close EmPShost.exe.
This can be seen for example with a script at logon that is executed but never closes therefore at logoff the Agent is still waiting for this action to complete.
To protect against this issue we recommend to add a maximum run time for the script.
By default this is set to 0 which will let the script run until completed. Changing this setting to 30 seconds for example to allow the script to only run for 30 seconds before the action is completed. In turn this will prevent any issues at logoff with a long logoff / hung session if this is caused by EmPShost.exe still running.
Further information on the EmPShost.exe process can be found in the following document.