49ers defeat Chargers in preseason finale at Levi's