This is actually one of my favorite topics in WW2. The short answer is: To the extent that YOU probably mean "winning"-- probably pretty close. The longer answer is much more involved and essentially boils down to "the war would have lasted much longer than it did, most likely, and it's impossible to know the results of what could have been".
What I think you're REALLY asking here is how close things went to going the other way, and that's what fascinates me so much, because it truly was very close. Here are some of my favorite examples:
While estimates vary, it is commonly agreed that if Goering and Hitler had continued to bomb the RAF airfields rather than initiating the Blitz, they would have reduced the RAF's ability to resist to a point that they would have gained full control of the air over Britain in a matter of weeks. This would have been, in my opinion, the biggest change that could have gone the other way. The Blitz did a lot to crystallize the British people towards the cause, allowed the RAF to rebuild and continue to resist. In my opinion, the failure of the Luftwaffe in The Battle of Britain is the true turning point of the war in the ETO.
There's always the classic example of "if someone had just woken Hitler up on D-Day and gotten the panzer regiments into Normandy that night, things would have been different" and there's a lot of truth to this as well-- a few established panzer regiments waiting in towns like Bayeux (which was out of range of the naval guns but still within an hour of the beaches) could have been on the bluffs to resist the invasion and would have made the job of getting up off the beach quite a bit more difficult.
In the same vein, if Hitler had authorized Rommel and Von Rundstedt to give even a LITTLE ground, things might have gone much differently. The Germans wasted incredible resources on the beaches trying to throw the invading allies back into the channel. In reality, it probably would have been a more effective strategy to allow the allies to mass on the beaches and bluffs above the beaches, and contain them in a pocket out of the range of their naval artillery, attempting to cut them off and isolate them from their supply chain-- Once the allies were able to establish an uninterrupted supply chain, it was essentially inevitable (though certainly not simple, given the work that was done before Patton's eventual breakout). This one is a bit more debatable in history, but my personal opinion has always been that a more malleable defense in this situation would have been much more difficult to overcome for the Allied forces.
In the East, Hitler certainly underestimated the vastness of Russia, and the lengths to which it's leaders would go to overcome him. If the Russians had attacked in force, more strategically, rather than in a wave across the entire width of the country (attacking Moscow, Stalingrad, and Leningrad almost simultaneously), it is POSSIBLE (though not a sure thing) that he could have actually established a foothold in the country, rather than bouncing off all the way back to Berlin. As soon as they failed to capture Stalingrad, it was all over in the East.
This is also ignoring the war in the pacific, and the involvement of the Americans in the war. There is a lot of work discussing when the Americans entered the war, and whether that was avoidable in any way (as it certainly didn't help the Germans' odds in the ETO).
Anyways, to circle back to your original question-- I don't think Hitler actually got very close to REALLY winning the war-- his issues with resources and overextension were too great to overcome in the end, but the Allied victory was expedited to a great extent by some pretty remarkable fortune, and things could have certainly gone much worse than they did for them.
I'd love to discuss specifics in a bit more detail, but I tried to keep this relatively vague and high level just to spark conversation.
First of all, you must realise that WW2 did not have a clear end-game for the germans. There was no "kill all and rule the world plan" There were multiple reasons, each one "evolving" from the previous.
when Germany started to annex territories in Europe, it wanted to unite all the germans under one state. - goal #1
no other power (France, UK, Russia, US, etc) stepped in after the first territories were conquered so Hitler grew very confident. And he had a reason to, his army used doctrines and equipment far ahead of any other nation.
when France and UK finally declared war, the new war-goal was to beat them. - goal #2
the germans ridiculed the Maginot line and conquered France. Now UK was the last European super power confronting them. - goal #3, defeat UK.
a crazy Hitler decides to declare war on Russia. This was done due to many reasons, but the main ones: different political ideologies, fear of an attack from the russians, need for supplies (iron, grain). - goal #4,beat the russians.
the italians were useless in Africa so a war front had to be opened there and defeat England, or else Germany was exposed to air raids from both West and South. - goal #5, win Africa
the war is lost on the eastern front. Africa is also lost, Italy surrenders. goal #6, survive.
So, depending on what point in time you look at, Germany had different "winning conditions".
I'm sorry, but this question is best looked at in /r/HistoricalWhatIf. While there certainly are hard numbers that one cal look at, the conclusion is necessarily speculative, and as you can see from the... spirited... discussions in here, a clear, academically rigorous answer is not easy to come by.
As such, I've had to remove it.
I am not a historian, however if the nazis stuck to their "pact" with the russians, thus eliminating a two front war with Russia and just focusing on Europe and the allies. This would allow the nazis to send more troops, probably would have taken Britain, and Europe would be under the nazis control. However the US still was fighting in the pacific against Japan, and now having to fight a more centralized nazi military in France and Europe. Keep in mind too that the D-Day invasion was a 50/50 call, setting up a supply chain on the beaches was absolutely crucial to Allied success. That is just my theory and analysis I could be totally wrong, but I am sure you will receive a more detailed and fact based reply.
I would like to change the question into: How close were the allies to loose WW2? I think the evacuation of around 300.000 british and french soldier 1940 in Dunkirk was a massive win for the allies forces. These soldier and their early experience with nazi germany were the backbone for counterattacks (D-Day etc.). Source for the lazy Source for historians: Holmes, Richard (2001): "Dunkirk evacuation". The Oxford Companion to Military History. New York: Oxford University Press.
I look at what we call WWII as two simultaneous wars. A European war, and a Pacific war. Yes, its true that some of the belligerents were involved in both theaters, but I feel that breaking it down this way helps to understand things better.
With that in mind, yes, the Nazis did come quite close to 'winning' their war. I feel that they really would have settled with continental Europe, then rearmed, resupplied, and then maybe eventually try again for more.
I've got this crackpot theory that Germany really didn't want to fight Britain because they respected them too much, and because of they knew that the Germans, and the English were really the same people, coming from the same common origin. I strongly feel that the Germans could have cast the decisive blow to the English on the shores of Dunkirk, or during the battle of Britain, but respected England too much, and would have rather sued for peace. The European war was Germany's war to lose, and they did.