The Dow Jones Industrial Average snapped a five-session losing streak, aided by a late surge, and notched its fourth consecutive annual gain.