You have an intermittent problem. Mine did the same thing but would only stay off for a few days. Needed to do the intake gasket anyway. When I took out the sensors, the front one looked good but the rear one not so much. It had a light coat of crusted rust around the base and the mounting block for it had some corrosion on it. This all lead to a poor electrical/intermittent connection. My guess is you'll need to replace it soon. Do the intake gasket at the same time along with a new wiring harness for the sensors and call it a day.
The job looks more intimidating then it really is. Took me a day to do that, change out the belts and tensioners, replace upper and lower radiator hoses along with antifreeze. And I was really taking my time. That and the 40 mins I spent looking foe the purge valve gasket that dropped somewhere along the line.