Yes, Gary nailed it for you. Either your battery is bad, not taking a charge, or the generator is not charging. The electric PTO clutch causes a constant drain on a battery, so if the charging system is bad, or the battery is bad, that is exactly what happens. First the PTO disengages (because there's not enough juice to keep the magnet engaged, and then, if it was a gas engine, the engine would eventually die because there's not enough juice to make spark. In your case, since it's a diesel, it kept running until you got back to the barn because the diesel engine doesn't really need electricity to make it run (compression ignition). It may have an electric fuel pump, so I'm guessing that's why it eventually died.
First take your battery to be load tested. If it passes, then your alternator is likely bad. If I remember right, the little Kubota engine has either a Bosch or Hitatchi alternator. Either way, not a big deal, either get it rebuilt, or may just be easier to find a new one online. In the meantime, if you charge your battery up good the night before, you'll be able to mow for a while each time, but it will eventually die out just like it did this time.