The No Machine (NX) client allows you to choose between five types of UNIX desktop sessions: KDE, GNOME, CDE, XDM and "custom." In the first four cases the session startup is invoked via the normal route (like "startkde") and the NoMachine X server is destroyed when the session exits. In the case of a custom session, however, NoMachine doesn't know when your program has finished (it may have put itself in the background) so the X server stays running and you have to terminate the NoMachine session manually.
Make a wrapper script, save it as /usr/NX/bin/nxwrapper, and then make it executable (chmod 755). The script:
# Script origianlly found here:
nxnode=$(ps -o ppid= -p $PPID)
nxagent=$(pgrep -P $nxnode -u $USER -x nxagent)
exec kill $nxagent
This should take care of killing the X server after your session is completed.
To start an XFCE session, for example, you would use nxwrapper xfce4-session as the command to run. From the wizard, select "custom," then "Settings..." Check "Run the following command," and enter in /usr/NX/bin/nxwrapper /usr/bin/xfce4-session (or whatever the path is for your desktop GUI, flux box would be /usr/bin/startfluxbox). Then select "New Virtual desktop" and Save.