Take a look at the key switch. Unbolt it from the frame and take it apart if you have to. Check to see if the plug is properly attached to the switch also.
When the engine dies, what else quits?
1. Do you still have power to the lights, the horn, signals etc etc.
2. When it quits, will the engine still turn over?
Giving as much detail as possible helps in the diagnosis.