About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
A user closes the last window of a RemoteApp program, and a few seconds later the remote connection ends. On the server the session is still there, in a disconnected state, and it may still be there the next morning. Administrators looking at the session list, or at a user who says "it disconnected", can reasonably wonder whether something has failed.
Microsoft's page for this symptom says nothing has failed. The behaviour is intended, it has a precise rule, and one Group Policy setting controls what happens to the disconnected session afterwards. Below are the rule, how to see which part of it you are meeting, and the one change Microsoft documents. Nothing before the Fix section changes anything.
What the error means
When a user starts a Remote Desktop Services or Terminal Services RemoteApp, a Remote Desktop session is created and the application runs in it. Microsoft's page says any further RemoteApps the user starts from the same client before that session is logged off will run in the same session, and so will any notification area (system tray) icons the user launches.
Then comes the rule. When all active application windows and all user-launched notification area icons are closed, the session remains active for 20 more seconds. The page gives the reason: this allows time for the user to launch another application, and for applications to display final messages or perform other closing tasks. If no other application or system tray icon is launched in that time, the Remote Desktop Protocol (RDP) session is disconnected.
A longer Microsoft blog post on the same logic, first published in 2007, describes the difference from a full desktop. In a RemoteApp session there is no explicit way for the user to log off or disconnect the session, so the server decides when to disconnect it. The decision has two stages. In the first, rules decide whether the session should be disconnected. In the second, Group Policy settings decide if and when to log off the disconnected session.
That is why the user sees the connection end by itself, and why an administrator sees a lingering disconnected session.
Likely causes
The page describes one intended behaviour with several things that change what you observe:
| What you observe | Reason on Microsoft's pages |
|---|---|
| The session disconnects about 20 seconds after the last window closes | Stage one: no visible or active window and no user-launched tray icon, so after the 20 second wait the session is disconnected |
| The session does not disconnect although the user closed the main window | A visible or active window remains, or an application started directly or indirectly by the user still has a notification area icon |
| A tray icon is left behind but the session disconnects anyway | Microsoft's blog says a notification area icon that the user did not start, for example an antivirus icon launched by a logon script, is not taken into account |
| The disconnected session is still on the server a day later | By default disconnected RemoteApp sessions remain in a disconnected state indefinitely |
| Disconnected sessions disappear sooner than the RemoteApp logoff delay says | Another session limit setting, for example the one for disconnected sessions, has a shorter time and takes effect |
Neither the first row nor the fourth is a fault. The second and third rows explain why behaviour can differ between two applications on the same server.
Prove the cause before changing anything
All of these read only.
-
Time it. After closing the last window of a RemoteApp, count how long the connection takes to end. Microsoft's figure is 20 seconds of waiting before the disconnect. A session that ends at about that time is behaving as described.
-
Look at the session on the server. Task Manager's Users tab, or the Remote Desktop Services management tools you already use, show the session with a Disconnected status. This is general advice about where to look, not a step on Microsoft's page.
-
Check whether anything the user started is still running. Microsoft's blog gives the examples. A user starts Outlook, opens a Word attachment, and the session stays active until both the Outlook and Word windows are closed. A user starts Communicator, closes its main window, and the session stays active because the program keeps running in the background with a tray icon. If a session never disconnects, look for a program the user started that is still open or still has a tray icon.
-
Find out whether your servers already have session time limits. Microsoft says that the setting that logs off disconnected RemoteApp sessions is Set time limit for logoff of RemoteApp sessions, and that it is found under both Computer Configuration and User Configuration at Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits. Read what is already configured there, and the Set time limit for disconnected sessions setting beside it, before choosing a value.
Example (illustrative): at contoso.com.au a user closes the accounting program and the connection ends after a moment. Two hours later, on the RD Session Host rds02, her session is listed as Disconnected. Both observations match Microsoft's description: disconnected 20 seconds after the last window closed, left disconnected because no logoff delay is set.
Fix
If the behaviour is acceptable, the fix is to explain it. Microsoft points out a benefit: leaving the session disconnected allows later RemoteApps to launch much more quickly, because a new RemoteApp reconnects to the session instead of starting a new one.
If disconnected sessions sitting on the server are the problem, for example for scalability, Microsoft documents a policy setting that logs them off after a delay. Microsoft's blog says administrators use these settings for scalability reasons, and that the setting applies only to RemoteApp sessions that have no remote programs running that were started by the user, so there is no threat of data loss from it.
Risk: the next step makes the server log off disconnected RemoteApp sessions after the delay you choose. A short delay means users who return later start a brand new session instead of reconnecting, so their RemoteApps start more slowly. Microsoft's blog advises choosing a time limit that suits users without overwhelming the server with idle sessions, and says: "We recommend that you set other session limit policy settings that end the session to a time limit that is higher than the RemoteApp logoff delay policy setting".
Before you change the policy, write down the current state of Set time limit for logoff of RemoteApp sessions (Not configured, Enabled or Disabled) at both locations, and the values of the other session time limit settings. The page gives no command for this, so it is general advice, and the record is what lets you reverse the change exactly.
On the terminal server, as an administrator, open the Local Group Policy Editor (Start, Run, gpedit.msc). Go to the node above under Computer Configuration or User Configuration. Double-click Set time limit for logoff of RemoteApp sessions, click Enabled, choose the delay in the RemoteApp session logoff delay list, and click OK. Then at a command prompt run:
gpupdate
That refreshes the policy at once on the local computer. After the setting is enabled, disconnected RemoteApp sessions are logged off after the configured delay.
To undo it: open the same setting again and set it back to the state you recorded (Not configured, if that is what it was), then run gpupdate again. Sessions that have already been logged off by the policy cannot be brought back, but Microsoft's blog says the policy only logs off RemoteApp sessions with no user programs running.
The blog gives a worked example of a sensible value: a user closes programs at 5:00 pm and returns at 8:00 am, and an administrator chooses an 18 hour logoff delay, so the user's programs start quickly the next morning. The same example shows the interaction with another setting. If Set time limit for disconnected sessions is set to two days, a Friday 5:00 pm session is gone by Monday 8:00 am. If it is set to 12 hours, the 18 hour RemoteApp setting has no effect, because after 12 hours the session is logged off.
Confirm the fix
- After the delay has passed, a session that was left disconnected is gone from the session list. Test with a pilot user rather than waiting a day: choose a short delay on a test server first, then the value you intend to keep.
- A user who reopens a RemoteApp after the delay gets a new session, and after a shorter gap reconnects to the existing one. Both are expected.
- The effective setting is the shortest of all the time limits that apply. If sessions are logged off earlier than expected, look at the other limits, as Microsoft's page says the shortest period takes effect.
What to watch afterwards
- Complaints about slow RemoteApp start. They can follow a delay that is too short.
- Sessions that never disconnect. Look for a program or tray icon the user started, as in Microsoft's examples.
- Servers where the setting is configured at both the Computer Configuration and User Configuration locations. Use one place and keep a note of it.
- Any change to other session time limits. They interact with this setting.
Read next
Related articles you may want next.
- TroubleshootingRemote Desktop disconnects and cannot reconnect to the same session: "Because of a security error, the client could not connect to the remote computer"Remote Desktop drops and reconnects to a new session instead of the old one. Check sessions, then apply the keep-alive policy and security settings safely.Read article
- HostingFull remote desktop or RemoteApp: choose from the business workflowHow to choose a full remote desktop or published RemoteApp from application integration, files and peripherals, while keeping shared-host permissions separate from presentation.Read article
- HostingBrowser client or native Remote Desktop for hosted business appsChoose browser or native Remote Desktop access for hosted business applications by checking the devices, printing and everyday workflows your staff need.Read article
Risks and limits
These steps have not been run or lab-tested.
Microsoft's support page, last updated on 2026-02-12, describes the behaviour for Remote Desktop Services and Terminal Services RemoteApp in general and says the policy setting was introduced in Windows Server 2008. It gives no range of Windows Server versions, no figures for how many idle sessions a server can carry, and no recommended delay. The 20 second wait is Microsoft's figure; it is not a setting the page says you can change. The longer explanation comes from a blog post first published in 2007 and shown with a 2018 posting date; it uses the older Terminal Services names for the policy path. The blog post is not a vendor support page in the same sense, so check the current Group Policy path on your own server.
Sources
- RemoteApp sessions are disconnected when all RemoteApp windows and user-launched notification area icons are closed — Microsoft Learn, page dated 2026-02-12, accessed 2 December 2026
- Terminal Services RemoteApp™ Session Termination Logic — Microsoft Security Community Blog, posted Sep 07, 2018 (first published 2007), accessed 2 December 2026
This article was originally published on .