Like at_exit, but can be called from any domain.
The provided closure must be portable as it might be called from another domain. In particular, the primary domain may call exit, thus calling the provided closure even if it came from a secondary domain.