U.S. stocks closed higher by about 1.5 percent or more Wednesday, following a rally in global markets, but the major averages still posted the worst quarter in four years. (Tweet This)

"I think there's a lot of short covering going on. A lot of people looking at yesterday's dip as a successful retest of the lows," said Marc Chaikin, CEO of Chaikin Analytics. "We have to see how the market closes out this week and the first trading week of October."

The major averages closed about 7 percent lower for the third quarter, their worst since 2011.

Ilya Feygin, senior strategist at WallachBeth Capital, said the S&P came off its highs after hitting resistance 1,912-1,915. "We're trading just kind of technically in between there (and 1,877)."

"I think the data coming up is going to be very important. That's why (there's) volatility," he said. China releases PMI data late Wednesday ET and the key September U.S. nonfarm payrolls report is due Friday morning.

The Nasdaq composite closed up more than 2 percent, helped by gains of nearly 4.8 percent in the iShares Nasdaq Biotechnology ETF (IBB). IBB remained in a bear market, or more than 20 percent below its 52-week high, after a sharp sell-off in recent weeks. The ETF lost about 17.8 percent for the quarter, its first negative quarter in 11.

Chaikin noted that Apple underperformed the major indices with a gain of about 0.8 percent on the day. "The fact that Apple can't get going is negative for the market," he said. The iPhone maker stock posted a nearly 12.1 percent loss for the quarter.

"Nothing has changed fundamentally from yesterday to today except that most of the globe is rallying with weaker-than-expected data points, with the hope of more stimulus from central banks," said Ryan Larson, head of U.S. equity trading at RBC Global Asset Management.

"The key thing is, does the early strength ultimately equate to the strength at the end of the day?" he said. "As those shorts are covered that buying interest isn't there."

"I think that's certainly lending some credibility to the gains that are there," said Paul Springmeyer, senior portfolio manager at the Private Client Reserve at U.S. Bank.

"Investors are being more cautious and tactful, hence the heightened levels of volatility. We've been at pretty subdued levels (of volatility). I think any time you see multiple point percentage swings it's an overreaction," he said.

U.S. stocks closed mixed Tuesday, after plunging nearly 2 percent or more on Monday.

Crude oil settled down 14 cents, or 0.31 percent, at $45.09 a barrel. Oil struggled to rally amid concerns about a hurricane on the U.S. East Coast, news of escalation in the Syrian war, and a report that crude stockpiles rose far more than expected.

Copper spiked amid quarter-end positioning and news of an output cut in Chile. Commodities trading and mining giant Glencore continued to recover with a gain of more than 11 percent.

"It warns of these companies in terms of their debt and how they've managed their balance sheets," said Mark Luschini, chief investment strategist at Janney Montgomery Scott. "That to me is more a symptom of what's happened in the commodity complex than a signal."

Wednesday was the last day of September and the final day of the third quarter, the worst since 2011 according to Barclays.

"The third quarter to me reflected uncertainty about the Federal Reserve, the uncertainty caused by not knowing how the central bank is going to raise rates. If you get a good labor report that may steel the nerves of the Fed," said David Kelly, chief global strategist at JPMorgan Funds.

Concerns about spillover from slowdown in China and the timing of a Federal Reserve rate hike sent markets into correction territory, or more than 10 percent below their 52-week highs, in late August.

The major U.S. averages recently fell back into correction mode and were close to retesting the August lows Tuesday. The Russell 2000 held below its Aug. 24 low Tuesday and posted a 12.2 decline for the quarter, its first negative quarter in four.

"You have increasing chatter about the rally into the year-end and that raises the question, what's going to be the catalyst for that?" Luschini said, noting increasing focus on third-quarter earnings reports following Friday's employment report.

"We think this is still in the context of this being a correction rather than a bear market," he said.

"Hopefully we should be looking forward. We just came through a rough, 6-week patch. A lot of it was due not to fundamentals but emotions," Larson said. "We should be looking forward if ADP is any indication on a fairly consistent picture of the labor market."

U.S. Federal Reserve Chair Janet Yellen is expected to give the opening remarks at a Community Banking Research and Policy Conference at 3 p.m. ET in St. Louis, Missouri. Last week the Fed chief suggested that the central bank was still likely to lift interest rates before year-end.

The Fed chair did not comment on the U.S. economy or monetary policy in the prepared remarks, Reuters reported.

St Louis Fed President James Bullard, New York Fed President Bill Dudley and Federal Reserve Governor Lael Brainard are also scheduled to speak later in the day.

Developments in Washington could fall under the spotlight since the Federal Government runs out of money at midnight — unless Congress and the President approve a new budget or a continuing resolution.

The Senate approved legislation Wednesday to avoid a shutdown, while the House of Representatives is expected to vote on the bill later in the afternoon.

Failure to reach an agreement will result in a government shutdown Thursday.

The blue chip index ended the quarter down 7.58 percent, for its first three consecutive quarterly decline since 2009, with Nike up 13.8 percent as the greatest quarterly gainer, while Caterpillar plunged nearly 23 percent as the greatest laggard.

The Dow transports closed up 1.1 percent on the day but fell about 3.8 percent for the quarter, posting three consecutive negative quarters for the first time since 2009.

The S&P 500 closed up 35.94 points, or 1.91 percent, at 1,920.03, with consumer discretionary leading all 10 sectors higher.

The index posted a 6.94 percent loss for the quarter, posting two consecutive quarterly loss for the first time since 2011. Utilities was the only gainer, while energy plunged 18.1 percent as the greatest decliner on the quarter.

The Nasdaq closed up 102.84 points, or 2.28 percent, at 4,620.16. The index ended the quarter down 7.35 percent, halting 10 consecutive quarters of gains.