Hey, man. I'm so very sorry. I can understand the emotions that you must have had, especially coming on here to ask advice (as I'm sure you were talking this through with others at home). As others have said, though, deep down you already knew what you felt the right thing to do was. It just takes time to accept it. I struggle with the idea because we can't ask them what they want, and we're making that final decision for them.
Like the other guys said, try to focus on the 16 years of friendship that you shared. Not that it's over, but that you were able to give him that. So many dogs (and other animals, and people) never have that. I bet he absolutely loved being on that farm! I always wished that I could have given Niki freedom like that, but we all do what we can with what we have. Just know that you were a good friend to him.