Stocks rebounded from earlier losses on Thursday, as investors reacted to a reported deal between the US and Iran.