I use lua interfaces to get lua support in my C# program, the worker thread will freeze if the user submits code like this
while true do end
<
I have used two techniques to address this issue. The first is to call the DoFile or DoString method inside a separate Task. That way you can abort the thread. I do not know of any technique (say from within a hook) to exit the interpreter.
Another way would be to setup a separate Appdomain. Using this you can also set separate constraints (evidence and permission set) see CreateDomain for details.