Missed my point or am I missing something?
I did indeed miss your point
Restore() only executed the first line of code and not the rest of the test script.
I don't see how that's possible, since lua doesn't know anything about lines by that point. The code you pasted isn't valid.
for i =1,5 do
while n==1 do
print("Script successfully terminated")
works as expected for me, spamming 5 "funs" before quitting.