Imam Abu Yusuf discussing Fiqh on his deathbed
Here we see the judge and Imam Abu Yusuf (Ya’qub ibn Ibrahim al-Ansari al-Kufi, later al-Baghdadi, born in 113AH, died 182AH, may Allah have mercy on him), the companion of Imam Abu Hanifah, and his student who spread his knowledge and madhab, the judge of the three ‘Abbasid rulers: al-Mahdi, al-Hadi, and al-Rashid, the first to be called Qadi al-Qudat (the Supreme Judge): we see him on his deathbed, during his last moments in this life, discussing a matter of fiqh with some of his vistors, in order to benefit and teach, and not wishing to lose the last moment of his life without making use of it in benefiting himself and being beneficial to others. His student al-Qadi Ibrahim ibn al-Jarrah al-Kufi, later al-Misri, said:
Abu Yusuf became ill, so I went to visit him, and found him unconscious.
When he regained consciousness he said to me: “O Ibrahim, what is your opinion on this matter?”
I said to him: “While you are in this state?”
He said: “That is fine, let us discuss it, perhaps one may be saved by it.” Then he said: “”O Ibrahim, which is better in the casting of stones [during pilgrimage], to do so while walking or while mounted?”
I said: “Mounted.”
He said: “Wrong.”
I said: “Walking.”
He said: “Wrong.”
I said: “Say your opinion, may Allah be pleased with you.”
He said: “As for the case where one stops where one should make supplication, then it is better to do so while walking, but if it is elsewhere then it is better while mounted.”
Then I left him, and as soon as I reached the door of his house, I heard crying, and he died, may Allah have mercy on him. 
This is indeed the way of the scholars and imams, for they say: “Seek knowledge from the cradle to the grave.” 
 Thus was the scholars’ love for knowledge- seeking it and discussing its questions and problems even at the time of leaving this life! In ibn Hajar’s book Tawali al-Ta’nis bin Ma’ali Muhammad ibn Idris on the virtues of Imam ash-Shafi’i, he wrote that ibn Abi Hatim said he heard al-Muzanni relate that it was said to al-Shafi’i: “How would you describe your love of knowledge?” He said: “When I heard a word I had not heard before, the organs of my body wish they all could have the pleasure of hearing it like my ears.” It was said to him: “What about your concern for it?” He said: “It is like the concern of the greedy miser in seeking more wealth.” It was said to him: “What about your seeking of it?” He said: “It is like the seeking of a mother seeker her lost only child.”
 Note that this statement is not a hadith of the Prophet salallahu ‘alayhi wasalam as some people think. The fact that its meaning is correct does not allow one to attribute it to the Prophet salallahu ‘alayhi wasalam, for all that the Prophet salallahu ‘alayhi wasalam said is true, but not all that is true was said by him.
The story about Imam Abu Yusuf mentioned above is reported in Fada’il Abi Hanifah wa Ashabih (The Merits of Abu Hanifah and his Companions) by Abu’l-‘Abbas ibn Abu’l-Awwam, p730; also reported in Manaqib Abu Hanifah by al-Muwaffaq al-Makki, 1:481; Manaqib Abu Hanifah by Hafiz al-Din al-Kardaki, 2:405; and in al-Jawahir al-Mudiyyah by al-Hafiz al-Qarshi, 1:76.
Source: The Value of Time, by Shaykh Abdul Fattah Abu Ghuddah