Denny Hamlin won Sunday's Cook Out 400 at Martinsville Speedway, beating Christopher Bell to the checkered flag by 4.617 seconds.