Language:
كتاب الرقاق
81  
To make the Heart Tender (Ar-Riqaq)
(4)
Chapter: About hope and hoping too much
(4)
باب فِي الأَمَلِ وَطُولِهِ‏
Sahih al-Bukhari 6418

Narrated Anas bin Malik:

The Prophet (ﷺ) drew a few lines and said, "This is (man's) hope, and this is the instant of his death, and while he is in this state (of hope), the nearer line (death) comes to Him."

حَدَّثَنَا مُسْلِمٌ، حَدَّثَنَا هَمَّامٌ، عَنْ إِسْحَاقَ بْنِ عَبْدِ اللَّهِ بْنِ أَبِي طَلْحَةَ، عَنْ أَنَسٍ، قَالَ خَطَّ النَّبِيُّ صلى الله عليه وسلم خُطُوطًا فَقَالَ ‏ "‏ هَذَا الأَمَلُ وَهَذَا أَجَلُهُ، فَبَيْنَمَا هُوَ كَذَلِكَ إِذْ جَاءَهُ الْخَطُّ الأَقْرَبُ ‏"‏‏.‏
Reference : Sahih al-Bukhari 6418
In-book reference : Book 81, Hadith 7
USC-MSA web (English) reference : Vol. 8, Book 76, Hadith 427
  (deprecated numbering scheme)