Pentair MasterTemp 400 keeps shutting on and off- then stops trying

Try a new thermal regulator.

The heater can get damaged if you run it without a thermal regulator for long periods.