Two massive wildfires have killed at least 31 people and destroyed thousands of homes as exhausted firefighters battled to stretch containment lines.