Everything here is my opinion. I do not speak for your employer.
There is no such thing as reliably cleaning up after a test failure. If you could do things reliably, the test wouldn't have failed.
My latest project is Tailscale: the easiest way to use WireGuard and 2FA.