Stocks closed well off session lows on Wednesday after the White House hinted Canada and Mexico could be exempt from tariffs proposed by President Donald Trump.

The Dow Jones industrial average ended 82.76 points lower at 24,801.36 after falling more than 300 points. The closed just below breakeven at 2,726.80 after falling nearly 1 percent. Real estate and tech were the best-performing sectors.

The Nasdaq composite closed 0.4 percent higher at 7,396.65, hitting a session high in late-afternoon trade, as shares of Facebook and Alphabet rose 2.2 percent and 1.3 percent, respectively. The Russell 2000, which is made up of small-cap stocks, outperformed, rising 0.8 percent to 1,574.53.

White House press secretary Sarah Sanders said the plan could include carve-outs for Mexico and Canada, two key U.S. trade partners. Trump is expected to release more details on his tariffs plan on Thursday or Friday.

Stocks fell sharply earlier on news that Trump's top economic advisor, Gary Cohn, had resigned after the president proposed tariffs on steel and aluminum imports.

"Today's market action was impacted by the resignation of Gary Cohn. That creates uncertainty," said Terry Sandven, chief equity strategist at U.S. Bank Wealth Management. He noted, however, that the fundamental backdrop remains positive as earnings are still growing.

Cohn, the free trade advocate and former president at Goldman Sachs, chose to step down from his position after Trump announced that he would impose tariffs on steel and aluminum imports. Cohn's departure date is expected to come in the following weeks.

Investors were on edge following the announcement as Cohn is seen as someone who supports more business-friendly policies, and therefore is seen as well-liked by Wall Street. Cohn was also seen as a voice of reason in a White House that is seemingly in constant turmoil and he opposed the implementation of tariffs. His departure raised concerns that a trade war could take place in the near future.