Wall Street endured a turbulent week dominated by the Greek debt drama, Chinese stock market volatility and an hours-long shutdown of the New York Stock Exchange.
Through it all, US stocks swung dramatically at times only to finish little-changed.
For the week, the Dow Jones Industrial Average added 30.30 points (0.17 percent) at 17,760.41.
The broad-based S&P 500 lost a scant 0.16 (0.01 percent) at 2,076.62, while the tech-rich Nasdaq Composite Index fell 11.51 (0.23 percent) to 4,997.70.
Greece remained at the forefront after a decisive referendum vote against creditor-designed austerity measures dented hopes for a quick resolution to the crisis, prompting a global stock selloff Monday.
But sentiment remained fluid, and stocks rallied by Friday after Athens submitted a reform proposal that offered key concession on taxes and pensions.
All eyes will be on this weekend's negotiations.
"If they really do get a deal hammered out, I would expect the market to rally very strongly," said Tom Cahill, a portfolio strategist at Ventura Wealth Management.
If a deal is not struck with creditors, the risks are that Greece could default on its debts, its banks could crumble, and it could be forced from the eurozone.
But in the event of an exit from the eurozone, "I think there would be a considerable markdown in the US stock market," Cahill said.
"The markets have not come to terms with a Grexit, so hopefully there isn't one."
China was Wall Street's other main preoccupation, with plunges in the Chinese stock market on Tuesday and Wednesday pressuring US stocks as well on worries of a deeper slowdown in the world's second biggest economy.
But as with Greece, the view of China improved by the week's end after rescue measures undertaken by the Chinese government sparked a strong rally in Shanghai.
But some are skeptical the worst is over.
"I would say the decline is not complete because bubbles don't end that easily," said Hugh Johnson of Hugh Johnson Advisors.
- Tech glitch freezes NYSE -
The week's most unexpected episode was a shutdown of nearly four hours on the New York Stock Exchange on Wednesday due to problems with new software installed on its systems.
The outage briefly overshadowed Greece and China, but had little real impact as traders simply routed orders from affected NYSE platforms to the Nasdaq and other completely electronic exchanges.
Analysts said the outage ended up being a non-event for most investors, though it underscored the diminished importance of the NYSE's main trading platform.
"What's extremely interesting is that there was practically no change in stocks due to the glitch," said Gregori Volokhine, president of Meeschaert Capital Markets.
"If this had happened 12 years ago, there would have been panic."
Major corporate stories included health insurer Aetna's $37 billion deal to acquire rival Humana in a transaction that some analysts believe could lead to further consolidation in the industry.
Procter & Gamble announced plans to sell 43 beauty and fragrance brands to Coty in a deal valuing the assets at about $12.5 billion. The move is part of the consumer products giant's effort to streamline secondary brands to better promote best-sellers like Gillette razors and Head & Shoulders shampoo.
US-listed Chinese companies like E-commerce giant Alibaba and Internet search company Baidu felt the effects of the upheaval in Chinese markets, swooning when Shanghai tumbled and rallying when equities in the home market went back up.
Worries about China were also seen as driving weakness in Apple, which fell five straight sessions before rallying Friday. Apple has targeted China as a major market for its iPhone.
Earnings season got underway with reports from aluminium producer Alcoa, PepsiCo and others.
Next week's calendar includes reports from General Electric, Delta Air Lines and JPMorgan Chase and other giant banks.
Federal Reserve Chair Janet Yellen is scheduled to appear before congressional panels for a pair of semi-annual hearings on Capitol Hill. Major data releases include retail sales and housing starts, both for June.