Have you deployed your app using Shiny Server, RStudio Connect, ShinyApps.io, etc.? There are some cases where R processes will be terminated while users are connected, in those cases you won't see session$onSessionEnded.
If that doesn't match the description of what you're seeing, it'd be helpful to have more details about what you're doing. Thanks!