This is not so easy to answer, especially 2 cases, these could be completely different causes.
This video shows disassembly and cleaning, it is critical that the metal shaft remains in the pump, it should never come out. While the video shows a 6020, the 6040 is mechanically basically the same.
The foodtimer is roughly 10 minutes, when you hit the button, a capacitor is charged, it discharges, and it switches back on, it can happen that the button sticks, the button you push is actuating a momentary switch underneath, if you use it very often over a longer time, the membrane pad can deflect, this is simple to solve, back off the screws a half turn or so so the button has room to return. Ideally I would open the controller and inspect.
The pump has numerous safeties, something in the pump, running dry, running at a speed which is not the set speed, it will shut down in any of these cases. These are all designed to protect the motor from being destroyed, a damaged propeller assembly or any calcium deposits or debris can trigger these shut downs as can air in the pump.