Why can't you run multiple instances? Your "requirement" is very strange.
Perhaps your app needs to be split into a service that handles all the user-independent stuff and is only ever running one instance and another app that runs as the users on the machine and talks to the service.
There is a system event you can subscribe to
SystemEvents.SessionSwitch Event (Microsoft.Win32)[
^].
The problem is your application can shut itself down and quit, but it cannot restart itself as the user that currently has the active session.
You do NOT get the user of the session that is active or being deactivated. What you do get is a Reason the event was raised in the eventargs. The values of which are
here[
^].
You would need a second application that runs as the users from the registry Run key and subscribes to the SessionSwitch event. It would have to determine when to launch your single instance application. This includes launching the application when your "monitor" application is launched, tell it to quit itself when a ConsoleDisconnect is detected and relaunching it when ConsoleConnect is seen.
You're going to have to write an app to test what values you get in the event args when certain things happen so you can cover every possibility.