scope guard for lua vm