Rory McIlroy finished 17-under to win the Open Championship and complete the third leg of the career Grand Slam.