We use this internally to help prevent leaks:
https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers
https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers
That said, I don't know that they would have helped in the article's case. It looks like there was a higher-level resource getting leaked, which would also most likely leak these.