Should closing an application mean an operating system that kills the server process?
In this situation, the server does not know that it is killed. It will disconnect existing connections.
If, when you close the application, you provide a method for the sys administrator to manually close the server (perhaps by typing "exit" on the server console). Then the closing event will be a custom event, and you will need to code the listeners and inform everyone who has stayed on the server. In this case, it is possible.
Try adding more details on how your server is built or how it works.
source share