GuideUpdated 27 November 20267 min read

Closing the Remote Desktop window leaves MT4 running on the VPS; Sign out closes it. How to tell which one happened, and how to get the EAs trading again.

In short
  • Closing the Remote Desktop window disconnects you. The Windows session stays open on the VPS and MetaTrader keeps running with its EAs.
  • Sign out ends the session and closes every program in it, MetaTrader included. Shut down and Restart end every session.
  • To find out what happened, reconnect with the same user and run query user: a logon time from before you left means you resumed your session, a logon time from after you left means the old session ended.
  • Task Manager's Up time then separates a sign-out (Windows kept running) from a restart (Windows started after you left).
  • After a sign-out, start each terminal again and check the login, AutoTrading and the Experts tab. Exits the EA manages itself did not run while it was closed.

Closing the Remote Desktop window does not stop MT4. It disconnects you: the Windows session on the VPS stays open, and MetaTrader keeps running with its Expert Advisors until you reconnect. What closes MetaTrader is Sign out, which ends the session and every program in it, or a Shut down or Restart of the VPS. If you came back and found MT4 closed, one of those happened, and two checks on the VPS tell you which.

Closing the window keeps the session and MetaTrader running; Sign out, Shut down and Restart close them
Three ways to leave a VPS, and what each does to MetaTrader.

What each way of leaving does

A Windows session is your signed-in desktop on the VPS, with the programs you started in it. Disconnecting detaches your screen from it; signing out deletes it.

What you doWhat happens to the sessionMetaTrader and the EAs
Close the Remote Desktop window (the X at the top, or on the bar at the top of the screen in full screen)Disconnected, kept on the VPSKeep running
Your PC sleeps, shuts down or loses its internet connectionDisconnected, kept on the VPSKeep running
Lock the VPS screenStays openKeep running
Type tsdiscon in a Command Prompt on the VPSDisconnected, kept on the VPSKeep running
Sign out from the Start menu, or type logoffEnded and deletedClosed. The EAs stop
Shut down from the Start menuThe VPS powers offClosed until the VPS is started again
Restart, by you or by Windows UpdateEvery session endsBack only if they are set to start on their own

Microsoft's reference for tsdiscon states that programs running when a session is disconnected are running when you reconnect, with no loss of data. Its reference for logoff states that after a sign-out all processes end and the session is deleted.

Leave the VPS without stopping anything

  1. Leave each MetaTrader window open. Minimising is fine; File, Exit closes the terminal and its EAs.
  2. Close the Remote Desktop window with its X. If a message says the remote session will be disconnected, confirm it: that is the safe action.
  3. Do not open the Start menu to leave. Its user menu holds Sign out, and its power button holds Shut down and Restart.

Signing out before you walk away is a good habit on an office PC; on a trading VPS it stops the terminals. The steps for opening the connection in the first place, and saving it for next time, are in connecting to a Windows VPS with Remote Desktop.

Find out whether you disconnected or signed out

If MT4 was closed when you came back, check what ended it before you change anything.

  1. Reconnect with the same user name as before (usually Administrator). A different user gets a different session, and does not see the terminals of the first one.
  2. Open a Command Prompt and type query user. It lists each session with its state (Active or Disc, for disconnected) and its logon time; a > marks the session you are in (Microsoft reference).
  3. Read the logon time of your session and use the table below.
  4. If the logon time is after you left, open Task Manager (right-click the taskbar), go to Performance, select CPU and read Up time. Count back from now to see when Windows last started.
  5. Open the Journal tab of each terminal once it runs again. Its time-stamped entries for the login and for each EA being loaded show when the terminal last started.
What you findWhat happenedNext step
Logon time from before you left, terminals openYou disconnected; everything ranNothing to fix
Logon time from before you left, a terminal missingThe session survived; the terminal itself closed or crashedRead its Journal and Experts logs; see why a trading VPS gets slow
Logon time after you left, Windows up since before you leftThe old session was signed out: by you, a script, or a session time limitRestart the terminals (below), then check the time limits
Logon time after you left, Windows started after you leftThe VPS restartedSee autostart after a VPS reboot and Windows updates on a trading VPS
Your user name listed twice, one line DiscYou are in a new, empty session; the terminals are in the disconnected oneSwitch to it with tscon (below)

A terminal that is open when you reconnect is not proof that it ran the whole time: if your terminals are set to start automatically, they may also open when you sign in. The start time in the Journal settles it.

Two sessions for one user. Windows Server normally reconnects you to your disconnected session, because by default each user is restricted to a single session. If that restriction was turned off, a new connection can open a second desktop with nothing running in it, while MetaTrader carries on in the first. Note the ID of the line marked Disc in query user, then type tscon <ID>, for example tscon 2. The tscon reference says this connects you to that session and disconnects the current one. The empty session can stay. To remove it, run query user again and type logoff <ID> with the ID of the empty session, never the one that holds MetaTrader.

When a disconnect still ends the session

By default Windows keeps a disconnected session for an unlimited time. Group Policy can change that, and the Session Time Limits settings are where it happens (current names):

  1. On the VPS, type gpedit.msc in the Start menu and open the Local Group Policy Editor.
  2. Go to Computer Configuration, Administrative Templates, Windows Components, Remote Desktop Services, Remote Desktop Session Host, Session Time Limits. The same settings also exist under User Configuration.
  3. Set time limit for disconnected sessions: if it is enabled, disconnected sessions are deleted after that time, which closes MetaTrader exactly like a sign-out. Set it to Not Configured, or keep it enabled with Never.
  4. End session when time limits are reached: if it is enabled, a session that reaches the idle or active time limit set in the same folder is signed out instead of only disconnected. Leave it not configured.

If both the Computer Configuration and the User Configuration settings are set, the Computer Configuration one wins.

Get the EAs trading again after a sign-out

  1. Start each terminal from its own shortcut. If you run several copies of the same broker's MetaTrader, each one has its own folder and shortcut, as in running multiple MT4 terminals with the same broker.
  2. Look at the connection status in the bottom-right corner. If the terminal is not logged in, log in again from File, Login to Trade Account.
  3. Check that AutoTrading (Algo Trading in MT5) is on, and that each chart shows its EA in the top-right corner.
  4. Read the Experts tab for errors from the restart.
  5. Compare your open trades with what the EA should have done. A stop loss and a take profit set on the order are held by the broker's server and kept working. Anything the EA manages itself, such as a trailing stop, a hidden stop or a time-based exit, did not run while the terminal was closed.
  6. Leave by closing the Remote Desktop window.

If the EA still does not trade once the terminal is back, the cause is no longer the session: see EA not trading on a VPS.

When this is not the right fix

  • The terminal drops the broker connection while the session is fine. That is a connection problem, not a session problem: start from MT4 keeps disconnecting on a VPS.
  • You would rather not manage Windows sessions at all. For one MetaTrader account, Metatrader In Cloud is one MetaTrader 4 or 5 that opens in a browser tab, with unlimited Expert Advisors and nothing to install. You start, stop or restart it from the service page in the client area.
  • You use the Metatrader VPS (Linux). It runs an Ubuntu desktop reached through Chrome Remote Desktop, not Windows Remote Desktop, so the Windows commands on this page do not apply to it.

How this works on Dipgate

  • On a Trading VPS you connect with Remote Desktop, usually as Administrator, and Dipgate's Windows connection article says the same as this page: after you disconnect, the VPS stays on and your programs keep running.
  • Dipgate sets up autologin on the Trading VPS. Put each platform's shortcut in the My Platforms Autostart folder so it starts again after a reboot. If you change the VPS password, redo the autologin.
  • If you chose Shut down by mistake, start the VPS again from the client area, where you can also stop it, change its password and open the VNC console.

FAQ

Does MT4 keep running if I switch off my own PC?

Yes. MetaTrader runs on the VPS; your PC only shows its screen. Switching it off, putting it to sleep or losing your internet connection leaves the session disconnected, not ended.

Is it safe to lock the VPS screen?

Yes. Locking keeps the session and its programs running, like a disconnect. Only Sign out, Shut down and Restart close them.

Can I close the MetaTrader window and leave the EA running?

No. The EAs run inside the terminal, so closing the terminal stops all of them. Minimise it instead, or simply close the Remote Desktop window.

Does Sign out from the phone app close MT4 too?

Yes. Signing out ends the Windows session whichever device you are connected from. On a phone, leave the app or close the connection instead.

My EA stopped but query user shows a logon time from before I left. What now?

Then the session survived and the terminal itself stopped or froze. Read its Journal and Experts tabs, and check memory and CPU on the VPS.