class Rack::BodyProxy

def close

then call the block the proxy was initialized with.
If not already closed, close the wrapped body and
def close
  return if @closed
  @closed = true
  begin
    @body.close if @body.respond_to?(:close)
  ensure
    @block.call
  end
end