[dll] finalize objects whose shared library is about to be unloaded