The following information is synthesized from The German War by Nicholas Stargardt, which is a social history of Nazi Germany that explores this very question.
According to Stargardt, the point that Operation Barbarossa stalled at the end of 1941, it was already apparent to some high level Nazis that the war was unwinnable. Certainly the tone of Nazi Propaganda changed at the end of Stalingrad in February 1943. Goebbels strategy was to portray the Battle of Stalingrad as a heroic loss where German soldiers fought to the last bullet in defense of their homeland. The loss of the entire Sixth Army at the end of Stalingrad, however, was so incongruous with the German public's perception of how the war was going, that Goebbels' framing of Stalingrad backfired to a large extent and led to a considerable amount disenchantment.
From there, Nazi propaganda as well as the hopes of high level Nazis rested on a few ideas. First, was the concept of secret weapons. Goebbels routinely hinted at secret doomsday weapons that could dramatically shift the momentum of the war back to Germany's favor. In reality, weapons like the V1 and V2 rockets, jet aircraft, and advanced submarines had a negligible effect in the face of the Allies' overwhelming material advantage against the Third Reich.
The second idea was the notion that the alliance between the USSR, UK, and USA could not hold due to the significant ideological differences between Western Democracy and Soviet totalitarianism. After the invasion of Normandy in 1944, many Nazi's believed that a victory on the Western Front could lead to separate negotiated peace with the US and UK, which would then free up German forces to concentrate on the USSR. Remember, the USSR was seen as a significantly larger threat as a result of Nazi racial ideology. The Ardennes Offensive in December 1944, or the Battle of the Bulge, was Germany's last effort to create the military conditions necessary for the pursuit of a political end to the conflict in the West. Once the clouds literally parted over the Ardennes, and the Allies' air superiority was brought to bear against a fuel-depleted Wehrmacht, the offensive came to an end. For the rest of the war Germany was unable to to engage in anything other than holding defensive positions. More importantly the Nazi's underestimated the extent to which the Allies were committed to a total German defeat. Even if the Battle of the Bulge turned out differently (it was still the costliest battle on the Western Front) and the Germans made a more significant advance, it would have been unlikely that the US / UK would have backed out of their alliance with Stalin.
The last desperate hope for Hitler came with the death of FDR in April 1945. Goebbels reminded Hitler of the story of Frederick the Great, who was on the brink of surrender during the Seven Years' War. At that desperate hour, the death of the Russian Czarina Elisabeth brought to power a pro-Prussian Czar and saved Frederick and his kingdom. With the death of FDR Goebbels said, history was repeating itself, but it's hard to tell who, beyond the Nazi's in Hitler's bunker and Hitler himself, took this quasi-super-naturally tinted prophecy seriously.