How to detect a closed boundary relation with Overpass Turbo?

Thank you for asking back.

I’d have expected a query like this https://overpass-turbo.eu/s/22x4
(with |(if: is_closed() == 1 )|) to return the complete one and not the
other - that works for closed linear ways, but it does not work here.

This is a little bit tricky. Closedness is for relations a property of
the referred ways and not of the relation itself. I.e. the same version
of a relation can be closed and not closed if already only the
underlying ways change.

I suggest the following approach:
this checks whether the totality of ways have nodes that are connected
to only one or three or more way segments. Those relations have
definitely a problem (which might be fixed by an edit to only member
ways, or new members), and relations where all used nodes are part of
exactly two segments have no problem of being not closed (could still
self-intersect).