How to terminate or disconnect a virtual session in NoMachine
This article applies to Linux only hosts running virtual desktops or applications in version 4 or later. The range dedicated to the Enterprise offers the functionality of virtual desktop. The free to download product "NoMachine for Linux" does not support virtual desktop sessions.
How to terminate a virtual desktop session
Terminating a virtual desktop session (Linux) in version 4 or later is done at the system level of the remote host. For example, if you are running a virtual desktop session (Gnome), you terminate the session by choosing the logout option from Gnome's system menu. (In version 3.5.0, terminating the session was done using the key shortcut Ctrl-Alt-T)
Next time you log in to connect, the session will not be available in the session list for reconnection.
How to disconnect a virtual desktop session
Disconnecting or 'suspending' the session is done by clicking the 'X' button in the upper corner of the window. Closing the window will disconnect your session.
Alternatively, you can disconnect via the NoMachine session menu panel (Ctrl-Alt-0 -> Connection -> Disconnect).
When you log in later, you will see this connection in the session list, and you will be able to reconnect.
Disconnecting or terminating a custom session
To disconnect the custom session close the client window showing the NoMachine menu.
To terminate the session, close the application window.
Disconnecting or terminating a session in web-based sessions
If you are running a virtual desktop session via the Web Player, the session is disconnected when the web page is refreshed or closed, or the browser itself is closed.
To terminate the virtual session running on the web, you need to use the logout facilities available in the system menu of your virtual desktop session.
Activating the Disconnect/Terminate Dialog
Starting from NoMachine version 4.4.12 it's possible to configure the server for displaying a dialog to let the user decide if disconnecting or terminating the virtual desktop session or custom session when clicking on the X button to close the session window.
This allow administrators to re-introduce the disconnect/terminate dialog typical of NX 3.5.0 but it will override the possibility of disconnecting the session by clicking on the X window button.
It will be still possible to terminate the session by executing log-out from the system menu.
The Disconnect/Terminate dialog is available since version:
- 4.4.12 for virtual desktops in X11 vector graphics mode (previously known as “lightweight” mode).
- 5.1.22 for virtual desktops not in X11 vector graphics mode.
- 5.1.7 for custom session.
To enable the Disconnect/Terminate dialog, enable the 'dialog' option (i.e. set 'dialog=1') in the following key available in the server configuration:
ConnectPolicy autocreate=1,autoconnect=1,automigrate=1,desktop=0,dialog=1,xsessions=0,udp=1
Disconnecting virtual desktops via !M menu
Starting from version 7, it's possible to disconnect a virtual desktop also via menu.
On your local device, right mouse click on the !M icon in the system tray and choose 'Quit NoMachine Player':

Disable the possibility to reconnect virtual desktops
If for some reasons, users should not be able to reconnect their virtual desktops, it's possible to completely disable session persistence. In this way, whichever method the user chooses for closing his/her session, the virtual desktop will be always terminated.
To disable persistence of virtual desktops, edit the /usr/NX/etc/server.cfg file and set:
DisablePersistentSession "all"
(Remove the pre-pending # from the key name)
To disable this feature for a number of users only, provide their usernames in a comma separated list, for example:
DisablePersistentSession "tester01,tester02,tester03"
How to terminate virtual desktops automatically
Please see this article for detailed instructions: https://kb.nomachine.com/AR08M00854
Terminating the session from Command Line
To terminate a virtual desktop or remote desktop session you can run:
nxserver --terminate SESSIONID or:
nxserver --terminate DISPLAYID
To terminate sessions of a certain user, run instead:
nxserver --terminate USERNAME
Finally, if you want to terminate all sessions, just restart the server:
nxserver --restart
or shutdown if you want to forbid new connections until the server is started again:
nxserver --shutdown
