Germany's population was on the brink of revolution at the end of WW I. Their navy had already mutinied once and whole battalions were breaking up as the stress of over four years' of war was taking its toll. Germany had huge casualties and now they were being pushed back towards their own country. They were no longer attacking towards Paris. With the entry of the US, a fresh country with a large manpool and a huge industrial base, even the rank and file German could see they were going to lose the war. They didn't want to fight knowing they were going to lose and the morale of their army had just about been broken. That's why units were disintegrating.
The High Command and Government saw what was happening and that is what convinced them it was time to surrender before a revolution like what was happening in Russia happened in Germany. They approached the Allies and asked for their terms and they were harsh, but at least Germany remained a single entity. The Austrian and Ottoman Empires did not fare as well and both were broken up and lost huge amounts of territory.