You can try with “custom scripts”, they’re also supported in the free version. Take a look at the following article:
Server Automation Interface: some examples to use custom scripts triggered on server/node events
https://kb.nomachine.com/AR02L00787
and any of the guides of the Enterprise products. Here’s the link to the Enterprise Desktop guide (like the free version but with more features) https://kb.nomachine.com/DT10R00171#11.3.
You could use, for example, UserScriptAfterSessionStart (in node.cfg) executed as user, not as user nx. Prepare your script and run it at disconnection to restore the previous monitor configuration.
#
# Specify absolute path of the custom script to be executed after the
# session start-up. The script can accept session ID, username, node
# host and node port as its input.
#
#UserScriptAfterSessionStart “”
or
#
# Specify absolute path of the custom script to be executed after
# the session is disconnected. The script can accept session ID, user-
# name, node host and node port as its input.
#
#UserScriptAfterSessionDisconnect “”