Fix resource leak in for loops

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