The 49ers dominated in the first half but had to hold off a second-half Commanders rally.