The Imams عليه السلام know when they will die and they die voluntarily
Al-Kāfi|Volume 1|Book 4|Chapter 47
3ـ مُحَمَّدُ بْنُ يَحْيَى عَنْ أَحْمَدَ بْنِ مُحَمَّدٍ عَنِ ابْنِ فَضَّالٍ عَنْ أَبِي جَمِيلَةَ عَنْ عَبْدِ الله بْنِ أَبِي جَعْفَرٍ قَالَ حَدَّثَنِي أَخِي عَنْ جَعْفَرٍ عَنْ أَبِيهِ أَنَّهُ أَتَى عَلِيَّ بن الحسين (عَلَيْهما السَّلام) لَيْلَةً قُبِضَ فِيهَا بِشَرَابٍ فَقَالَ يَا أَبَتِ اشْرَبْ هَذَا فَقَالَ يَا بُنَيَّ إِنَّ هَذِهِ اللَّيْلَةُ الَّتِي أُقْبَضُ فِيهَا وَهِيَ اللَّيْلَةُ الَّتِي قُبِضَ فِيهَا رَسُولُ الله (صَلَّى اللهُ عَلَيْهِ وَآلِه )
3. Muhammad ibn Yahya has narrated from Ahmad ibn Muhammad from ibn Faddal from abu Jamilah from ‘Abdallah ibn abu Ja‘far who has said that my brother narrated from Ja‘far (abu ‘Abdallah عليه السلام from his father that he went to Ali ibn al-Husayn عليه السلام on the night in which he passed away and offered him a drink requesting, “Father, please drink it.” He said, “Son, this is the night in which I will pass away and during such night the Messenger of Allah also passed away.” (The date of the demise of the two holy ones, as generally held, is not the same. However, being the same day is a possibility).
- Mirʾāt al-ʿUqūl fī Sharḥ Akhbār Āl al-Rasūl (3/121)
- Ṣaḥīḥ al-Kāfī