John Paul II wrote a letter of resignation in case he was not able to fulfil his duties
The pope wrote the letter in February of 1989, during the Cold War, a very uncertain moment in history. Back then he was 68 years old and healthy.
In the letter, John Paul II said he would resign from the papacy in one of two cases: one, if he had an “incurable disease” that would prevent him from exercising the apostolic ministry; or "in case of a severe and prolonged impairment that would’ve kept him from being the pope”. Perhaps the pontiff was thinking about an accident, an attack or a war. John Paul II entrusted in the Dean of the College of Cardinals, the cardinals of the Roman Curia and Vicar of Rome, to decide when to accept his letter of resignation.
The postulator, Slawomir Oder, published the entire text of the letter in his new book, "Why he is holy".