And why didn't they try to negotiate a peace treaty if they knew defeat was inevitable?
About one third of the German population realized the war was lost in late 1942 and early 1943 according to US Strategic Bombing Surveys conducted in1945. The Battle of Stalingrad was an essential catalyst for this shift in public opinion. One Augsburg individual said "The Führer has also spoken himself about how important Stalingrad is, and now he has gone and lost it."
It's also important to realize that Stalingrad was only one of several major reverses (losses in North Africa and the increasing presence of Allied bombers). What was rapidly becoming clear to many Germans was that the war was not going to be brought to a rapid conclusion and the tide had shifted against Germany. SD reports indicated that Stalingrad acted as a symbol for Germany's wider fortunes, and created "a general feeling of deep shock" and that there "there is a general conviction that Stalingrad signifies a general turning point in the war."
The central problem for a peace treaty was Hitler and the Nazi regime itself. Hitler had created no mechanisms for the creation of any new government or state mechanisms to replace him. This contrasts strongly with Mussolini, who could be dismissed by the king and the Grand Council of Fascism, and the Japanese which maintained its Emperor-appointed cabinet system. Hitler was simply not interested in a peace treaty or overtures. Also, the very nature of the Third Reich had become so ideologically toxic among the Allies that a separate peace was a political dead letter within the Allied leadership. The nature of how Hitler's threat was perceived is illustrated by the fact that FDR New Deal liberalism, Churchill's British imperialism, and Stalin's communist dictatorship (three very different styles of ideology and attendant mentalities about how the world functions) were able to cobble together a roughly functional relationship during the war so long as Hitler existed.
Sources
Evans, Richard J. The Third Reich at War. New York: Penguin Press, 2009.
Kershaw, Ian. The "Hitler Myth": Image and Reality in the Third Reich. Oxford: Clarendon Press, 1987.