Major stock indexes ended higher for a third straight session Tuesday, hours ahead of a deadline for congressional leaders to keep the U.S. government open.