I started having a similar problem with my old Same 35. It would sometimes shut off for no reason, sometimes cold, sometimes hot. As I dug into the wiring diagram and studied things, the fuel solenoid shutoff is controlled by an electrical "box" circuit. It is normally "off" while running. The solenoid typically has a spring and is in the ON position (i.e., not shut off). When you turn the key on, it starts a cycle in the "box", and when the key is shut off, the box cycles and sends voltage to the selenoid, shutting off the fuel, but only for a period of time, say 20 sec or whatever the design is. After that, the fuel solenoid voltage stops and solenoid opens back up to it normal "run" position (no voltage).
On mine, I had a frayed wire that would intermittently, briefly interrupt voltage to the "box", which would then send voltage to the fuel solenoid, as though the key had been shut off. So in other words, any brief electrical signal interruptions will tell the box to sent voltage to the solenoid and shut it off. Half a minute later, the tractor will start right back up with nothing wrong. So this can be a frustrating problem. An easy way to check it is to find the fuel solenoid. It should have two wires going to it. Just disconnect one of the wires to break the circuit. The solenoid will remain in its normally open position, and the tractor will start and run just fine. Of course, shutting the key off will have no effect. But you can reconnect the solenoid, cycle the key on and off, and you should see the solenoid activate and close. Later, it will click and re-open, after the engine has stopped.
As Rj suggested above, one of the several safety interlock circuits are probably fritzy, and sending a signal to the black box to shut off. You'll just have to track which one, by disconnecting the clutch, brake or whatever else one at a time to see where it is coming from. Or, theoretically you can just disconnect the solenoid wire, run the tractor, then reconnect it and shut it down with a key cycle when done (not highly recommended).