ANSWER: There is no sure answer to this question because the Bible does not reveal to us the details concerning the John's death. Information regarding his last days comes to us primarily from tradition. The 1913 Catholic Encyclopedia, in an article on St. John the Evangelist, states that writers in the second and third centuries A.D. recognized and accepted a widely held tradition that the apostle spent his last days in Ephesus.
According to the Catholics, Justin Martyr also referred to John as one of Jesus' apostles who lived in Ephesus. St. Irenaes, Eusebius and still others, again according to the Encyclopedia, all agree that after leaving the isle of Patmos (where he was banished to for preaching the gospel, see Revelation 1:9) John spent his remaining days in Ephesus until he died somewhere around the close of the first century.
A well-known reference book on New Testament Martyrs, written by John Foxe (1515 - 1587), states that the apostle, as punishment for being a believer in Christ, was thrown into a cauldron of boiling oil.
"From Ephesus he was ordered to be sent to Rome, where it is affirmed he was cast into a cauldron of boiling oil. He escaped by miracle, without injury. Domitian afterwards banished him to the Isle of Patmos, where he wrote the Book of Revelation. Nerva, the successor of Domitian, recalled him. He was the only apostle who escaped a violent death" (Foxe's Book of Martyrs)
The Emperor Domitian reigned as Roman Emperor from 81 to 96 A.D. He likely banished the apostle to the island of Patmos, which is near the coast of Asia Minor and the city of Ephesus, in 95 A.D. His successor, Nerva, who ruled the world empire from 96 to early 98, likely released John in 96 from his banishment to Patmos. This last living person who witnessed the transfiguration of Christ (Matthew 17:1 - 9) was likely the only one of the original twelve disciples to die a peaceful death and escape a violent martyrdom.
Easton's Bible Dictionary writes that John 'retired' to Ephesus after writing Revelation. The aged apostle, according to Easton's, outlived just about all his friends and his many acquaintances made over the years.
In conclusion, research into your question has lead to the conclusion that John was exiled to Patmos in 95 A.D. It was during his stay on the island that he not only wrote the Book of Revelation but also finished writing his gospel account. After his release, he finalized the arrangement of books and the canonization of the New Testament around 96 - 99 A.D. John, the last living person who was directly taught by Jesus during his ministry, lived a long life and died close to 100 A.D. Evidence suggests He ended his days in the Asia Minor city of Ephesus.