it's not a
car, sounds like at large riding mower of some kind., not told
fails parked, and idling or in motion, or both> not told this key fact.
you forgot to say MTD, makers name, ZT42 sure. , makers matter most. MMM
ZT = zero turn model is guess.
not told how old it is.
nor how many seasons run?
this must be your first mower repair?
the engine on most large mowers have 4 more more cutout switches that love to fail even the engine can have low oil (pan) sensor that trips , for lack of oil
the mower came new with users guide and full schematic, if not get it from the maker first.
causes:
(safety devices lots) MTD. ZT series.
1: seat switch bad.
2: clutch switch shows engine to deck is ingaged when not ingaged.
3: ignition switch failing. loose wires to it?
4: brake switch bad, shows brake off when parked. idling and stalls. on purpose.
5: gear lever in wrong location, switch (marked LH lever is schematic)
relays to any above too can fail. (safeties)
some mowers have PTO and that too has safety switch. to fail. if opted.
and engine oil low.
and carb dirty, clean it.
answering for Large motor stalls (riding size huge) 23HP
google shows this.
https://www.partstree.com/models/915148-zt-42-gravely-42-zero-turn-mower-sn-000101-009999/wiring-diagram-16/
the schematic is there, I guess, but MTD actual is best to ask.
shows PTO too.