William Byron beat Ryan Blaney on a late-race restart before taking the checkered flag at Martinsville to clinch a berth in the NASCAR Championship 4.