You got it.
The module inside the magneto is failing when it get hot.
When it cools down ( 30 minutes) it will work again.
Double check by testing for a spark at the plug when the mower cuts out with that wire still disconnected.
Also check the engine side of that wire.
In running mode, brake off, bum in seat PTO turned on the wire should be open .
Bum off seat Pto on and the wire should go ground
As per the previous post.