Stocks ended lower Thursday after struggling all day following a steep sell-off in the Chinese stock market and the approaching deadline for cash-starved Greece to make a debt payment.

At the close on Wall Street, the Dow Jones industrial average was down nearly 37 points, about 0.2 percent, at 18,126.1. The Standard & Poor's 500 index lost 2.7 points, about 0.14 percent, to 2,120.8, and the Nasdaq composite gave up 8.6 points, about 0.2 percent, to nearly 5,098.4. While still down, all indexes had recovered slightly from where they were trading during the day.

advertisement | advertise on newsday

ENERGY: About the same time, the price of benchmark U.S. crude rose in choppy trading after data showed a fourth weekly drawdown in U.S. crude stocks. The price on the New York Mercantile Exchange was $57.85 a barrel, up about 34 cents. It continued to rise in after-hours trading.

CHINA DIVE: The Shanghai Composite sank 6.5 percent in another volatile move. Stock market commentator Hexun attributed the fall to several factors including brokerages tightening margin lending, selling by speculators and a Chinese sovereign wealth fund selling shares in two state banks.

Despite a deepening economic slowdown, the index has gained 40 percent in the past three months alone. Chinese leaders have tried to tap brakes on the stock market boom, fearing it could run out of control and disrupt economic reform plans.

GREECE FACTOR: Traders continue to get mixed messages about the progress of talks between Greece and its creditors. Greece said Wednesday it expected to reach a deal to get more bailout loans in time for it to make a key debt repayment on June 5. But its creditors, however, were quick to temper expectations.

THE QUOTE: "With the situation in Greece rapidly coming to a head and election results showing disenchantment with the status quo and the establishment across the continent, the pressure to reach a solution on Greece has grown rapidly," said Nicholas Teo, analyst with CMC in Singapore, in a market commentary. "Developments on this front may continue to drive trading action in the coming days."