GCed languages often also have a mechanism for running code on scope exit. For example Lua's <close> attribute, which runs a metamethod when it goes out of scope rather than having to wait for GC:

  function readfile(name)
    local f <close> = assert(io.open(name))
    return assert(f:read"a")
  end