Ensure body is closed inside the proc just as it would be outside the proc

Serving the body is wrapped in begin/ensure/end so that body.close is
always called if there are any problems. Now that looping over the body
happens in a proc, the proc has to have its own begin/ensure/end block
to guarantee the same behavior.