Lua shutdown hook and logging api