Hi all,
I've come to the conclusion that this problem is unsolvable and I will abandon the idea of an at-exit-hook. The most serious potential consequence of running it in really_cleanup_for_exit(), which is indirectly invoked through atexit(), is that the resources to clean up or the Guile library itself has already been deallocated.
Also, calling it from scm_boot_guile is a half measure since the application might exit from main_func(). I thank Chris and Maxime for pointing out the problems.
I actually think that I tried to do this (introduce an at-exit-hook) 25 years ago, with the same eventual realizations, but didn't recall that at first. Brace for 2050! :-))
Best regards,
Mikael