FWIW, every gremlin is a bit different. When I had a similar issue while trying to get home from Dons MD, I ended up finding 3 possible issues that could have each by themselves caused the intermittent dying.
1. broken kill switch. I scrounged a new one.
2. there are 2 black wires connected to the battery Negative post, one is the heavy one that goes to the engine block for the starter current, and the other one is smaller that goes to a 1 pin connector and then to frame ground. The one pin connector on mine had at some point in its life gotten doused in battery acid and was very corroded, I cut that out and made it a one piece wire from battery to frame.
3. In a connector in the dash the red/white wire, (same wire that goes to the kill switch) had a bad factory crimp to the terminal in the connector while I was wiggling wires this one simply fell out of the terminal. I soldered it back into the terminal.
Any one of these could have been causing my issues so I have no idea which one fixed it. But I spent a month chasing wires around the bike to find them.