RAII helper to not depend on `~` implementation details