We already use packageEvent("rstudioaddinflowr", "onUnload") which works fine when the package is unloaded, but isn't called when the R session ends.
I already tried .Last and .Last.sys, as well as reg.finalizer, none of which seem to actually be called.
The same shutdown hook should be run when the session exits as when the addin is unloaded: https://github.com/flowr-analysis/rstudio-addin-flowr/blob/main/R/shell.R#L5-L15