Fix #17216

Trans the cleanup scope of for loop bindings so we don't leak resources.  Regression test included.