US stocks end with gains on hope for extended tariff deadline