It should bring up a fault code when you unplug the flywheel sensor.
What is the tip of the sensor like? Any damage?
Should have 0.5 mm gap between the sensor and flywheel when fitted.
Sounds like an electrical fault that may be heat related.
I have had strange faults before and turns out to be the ignition switch.
Have you checked this when it shuts down?
This is ONLY to be used to report flooding, spam, advertising and problematic (harassing, abusive or crude) posts.