Commenter Matt Steinglass takes me to task for this claim. I suppose it depends on what you mean by ending the Great Depression.
The Great Depression indisputably ended during World War II, which is when the output gap closed. But was it causal? Like everything else about the Great Depression, it's really hard to know.
Christina Romer convincingly argues that it was ultimately monetary expansion, driven by gold flows into the United States, that ended it--but later in the decade, before the turnaround, those gold flows were driven by fears about the war that indeed eventually came. Lend-Lease represented a substantial credit expansion.
There are other non-spending factors. Commodity prices spiked in 1939 due to the war, which was good for the resource-rich American continents. American labor started leaking abroad as foreign labor markets tightened. Undoubtedly a lot of firms who made things that warring Europeans needed saw a dramatic improvement in their optimism. Our figures for the period are rather primitive, so it's harder to measure things like business confidence than it would be now.
One thing that makes the question difficult to answer is that it's hard to know when to date the beginning of the recovery. Matt prefers 1940, but argues that net exports cannot justify this as a result of war spending. (By 1941, I think, you cannot reasonably read US history and conclude that America was not defacto ramping up production for a war) But there had been another nasty recession in 1938, and recovery after recessions is unusually fast. Economies are complicated things. Absent the war, would the economy have grown in 1939 and part of 1940, then sunk back into the doldrums? I don't think we know.
Here's the interesting thing, though: if you want government spending to be the solution to the problem of the Great Depression, you want Matt to be badly wrong, because the timing doesn't back up that belief. Most macroeconomists would say that stimulus comes from deficits--but the deficits during 1939 and 1940 were not high relative to earlier years, except 1938. The 1938 contraction in government spending may have produced the 1938 economic contraction--or, as conservatives would prefer it, stopped artificially inflating measured GDP. But the deficits in the late 1930s do not back up the "more is better" philosophy animating current stimulus debates; if anything, they rather suggest that "less is more". Nor were the government spending figures particularly high, if you were planning on arguing that outlays rather than deficits produce growth.
There is no simple narrative of the Great Depression that allows you to atttribute the ultimate recovery to trend output to the simple magic of the New Deal. That's why people like Paul Krugman focus on the high deficits and spending levels of World War II.