As Democrats lose House, Nancy Pelosi’s historic reign as speaker ends