Hope this raises your question, but at least hope it helps (and it takes too long for comment).
This is the goal for which load balancing is most important, you can control how much traffic a particular server receives until you need to close the server, you can safely say that it is not used anymore. Since you have websites open directly with the server, it is very likely that these connections will be stored directly on this server and cannot be proxied through the load balancer (not sure about this), but not creating new connections will eventually make these compounds eventually die off.
As an alternative, consider the option of balancing the load for the poor person and configure a proxy server on this server, which will hit other servers. If all your state is saved through a common database, no operations will be violated, and you can give enough time (whatever that is) for the event loop.
Regarding the use of the server, if you donβt have a way to tell what is happening with the event loop, all the application logs that you have on the server can help determine what your application is doing, and just fine the court will tell you how safe it is to close him at a certain point. (Again, the more you can reduce the use on it before that, the better.)
Finally, as Archimeding suggested, using process.on() to handle graceful completion is pretty much the standard across all platforms. (It makes me remember a lot of Java-based servers that take some time to close.) Depending on the severity of the effects of the application endlessly, you might want the process to hang a little longer or even perform shutdown procedures, but you have to consider that this not always possible.
Finally, try to avoid dependency on any particular server. Controlled shutdowns are easy to handle, but outages and hardware failures will not allow you to wait for a cycle of events.
Alpha source share