Rafael Nadal beat Dominic Thiem to win Madrid title