RAII only works for resources acquired and released (directly or indirectly) by stack-allocated objects, where there is a well-defined static object lifetime.
In C++, stack unwinding is only guaranteed to occur if the exception is caught somewhere.