I have a long time fly program, it is a player. After it started, it will load and run Lua code from net by the server\'s command. Each code have a unique named module.
Module in Lua is just another table with all the functions and variables inside. If you set it to nil and remove the entry in package.loaded it should be cleaned by the garbage collector.
Here's a function implementing module unloading:
http://lua-users.org/lists/lua-l/2009-03/msg00587.html