I haven't seen this happen to a B model but, I did see a C model have the lockout solenoid stop the machine like this.
The relays have been extra reliable, I have never replaced the ones that work the solenoids.
If you are loosing power to all the cab, then I would say it is the main relay going bad.
Since it is just the hydraulic, I would believe the lockout solenoid should be replaced first.
If this is not the issue, you will need to access the monitor to find the active fault code when the problem appears.
This solenoid is directly under the cab, access through the bottom plates. I think it will be the second from the front plate.
Look for a valve with several lines connected to it and a single solenoid. It is part number,(###) ###-#### ***** has changed numbers a few times but, it is large enough you will see it easily.
If you need further help, please post the full machine serial number with your request.