Scottish actor/singer Billy Boyd struggled to find the right words to bid a fond farewell to Middle-earth as he sat down to write the song which will play over the end credits of the final movie in The Hobbit trilogy.

The star, who portrayed the hobbit Pippin in the Lord of the Rings films, teamed up with director Peter Jackson and writers/producers Fran Walsh and Philippa Boyens to pen the fittingly-titled The Last Goodbye for The Hobbit: The Battle of the Five Armies soundtrack, but he reveals it took them some time to get the lyrics and tune just right as it not only marked the end of The Hobbit sequel, but also the conclusion of the entire fantasy series based on the books by J. R. R. Tolkien.

Boyd, who fronts the band Beecake, explains to, "We had to get the song just right, to send the audience out of the movie theatre in the most perfect way we could...

"A lot of ideas took us to dead ends or we found the tone wasn't just right. I think we discovered very quickly this wasn't just a song to end The Battle of the Five Armies - it was a song to say goodbye to Middle-earth."

And Boyd admits he was really flattered to be invited to tackle the project.

He adds, "The Lord of the Rings films were such a special time for me in many ways - working with Pete, Fran and Philippa, being in New Zealand, being part of Professor Tolkien's work or even just the incredible friends I made. And being asked to go back to that, to work in that wonderful fantasy world again and to be singing the song that says goodbye to Middle-earth for everyone involved and the fans who took this beautiful journey with us is truly a great, great honour."

Boyd's efforts have been warmly received by The Hobbit stars Ian MCKellen and Elijah Wood.

The veteran British star shared a link to the song's video with fans on on Sunday (23Nov14), alongside the message: "The Last Goodbye makes a perfect ending", while Wood writes: "This is truly beautiful and a fine farewell to Middle-Earth and our friends and family. So proud of @BillyBoydActor".

The Hobbit: The Battle of the Five Armies is due to open in movie theatres next month (Dec14).