OK, so people have brought up two issues:
1. It is for various reasons not recommended to call atexit() from a dynamically linked library (which Guile already does before my suggested change, n.b.).
2. It is not async signal safe.
A suggested remedy would then be:
Instead of calling the at-exit-hook from really_cleanup_for_exit, we could call it (still within an scm_with_guile) from the end of scm_boot_guile(), just before exit(), with the disadvantage that it wouldn't be called if main_func() calls exit on its own. It's kind of a pity that we didn't early on introduce some kind of scm_finalize_guile() which the user would have to call when done with the library...
And, well, perhaps we should block asyncs, but I don't know about signals with this new setup.
Best regards,
Mikael