Workaround bug in finalizer and/or weak table semantics in Lua implementation.

See the comment in the patch for more details.