We do not know what happened to the apostle John after the biblical account of his life ended. One of the New Testament gospels now bears his name as author, although it was anonymous until later in the second century, in which case he not only preached the gospel but wrote an account of the mission of Jesus. However, as John Carroll says in The Existential Jesus, at page 228, most scholars assume that John did not write the gospel. Burton L. Mack says in Who Wrote the New Testament, page 215, that before what is now known as John's Gospel was attributed to John, it had already become popular in gnostic circles where it was said that Cerinthus, the founder of a gnostic school, had written it. One way or another, we can say that the apostle John did not write the Gospel or epistles that became attributed to him.
Mack says (ibid, page 197) at some point, the Revelation to John of Patmos was associated with the writings of the Johannine school solely because of the common name. This is two stages removed from the apostle John, first by the assumption of common authorship with the Gospel in spite of very different theology and style, second by the assumption that the apostle John wrote the fourth gospel. Once again, there is no reason to believe the apostle John wrote this book, and many scholars now refer to its author as 'John of Patmos' in order to avoid confusion.
Thus, we can not say that John, son of Zebedee, spent his latter years writing. We have no reliable information as to where he went to preach, if at all. There is no historical evidence that he travelled to Ephesus where he took care of Virgin Mary or that he lived there until the end of his life.