This problem occurs when users use a tcsh shell. In this case the server is unable to retrieve the pid of the virtual desktop and complete the procedure for terminating the session which is then forcibly killed.
This happens either when (i) the user terminates the session or (ii) when the session is terminated automatically by the server because session limits are reached.
In this last case (ii), nxserver/nxnode processes are forcibly killed and custom scripts set in the server.cfg/node.cfg file cannot be therefore executed. In the first case (i), instead, the nxserver/nxnode processes aren't killed and custom scripts triggered on server/node events are executed.
A temporary solution can be to adopt a different users' shell, possibly bash.