Why did the Germans agree to a cease fire?

In World War I, the Germans agreed to a cease fire when they realized that the war was lost. The Armistice was signed on November 11, 1918.