LUA connector fails after a stream is stopped

Update this:

local req_headers = {
  ['Accept'] = 'application/vnd.twitchtv.v5+json',
}

to

local req_headers = {
  ['Accept'] = 'application/vnd.twitchtv.v5+json',
  ['Client-ID'] = 'YOURCLIENTID'
}

Somewhere in your code you are making a request without an attached oAuth and thus are missing a ClientID.