JJ Spaun won the BMW PGA Championship by two shots after a string of late birdies.