Running something atexit after all finalizer

I have some finalizers
they need to ccall in order to free some external resources.
I also have a function I need to call right at the end which completes the tear-down – it undoes something I do in __init__.
That at-exit function removes parts that are need to run the finalizers.

Right now I am getting errors because the atexit is running before the finalizers.
Which means the finalizers error

Is it feasible to check whether the resource is released in the finalizers?

That is is what I am doing right now. Works for me.
But it seems like a nonideal solution – what if I really did need those finalizers to run?
Like if they were controlling some physical device.
(One probably shouldn’t do that with finalizers, since a hard crash would prevent anything running, but it might make sense sometimes as a extra check)

Perhaps less weirdly, if they were going to free some element in a collection.
And the atexit was going to free the collection.
So freeing the collection without freeing the elements would leak memory.

What’s the way to do resource management in the C/C++ library? It’s better to follow the same style, sometimes we may need to implement (intrusive) reference-counting manually though.