In the 2010 book interview by Peter Seewald Light of the World, pp. 29-30.
Seewald: Have you thought of resigning?
Pope Benedict: When the danger is great one must not run away. For that reason, now is certainly not the time to resign. Precisely at a time like this one must stand fast and endure the difficult situation. That is my view. One can resign at a peaceful moment or when one simply cannot go on. But one must not run away from danger and say that someone else should do it.
Seewald: Is it possible then to imaging a situation in which you would consider a resignation by the Pope appropriate?
Pope Benedict: Yes. If a Pope clearly realizes that he is no longer physically, psychologically, and spiritually capable of handling the duties of his office, then he has a right and, under some circumstances, also an obligation to resign.