Ibn Abbas reported:

When Allah's Messenger (ﷺ) was about to leave this world, there were persons (around him) in his house, 'Umar b. al-Kbattab being one of them. Allah's Apostle (ﷺ) said: Come, I may write for you a document; you would not go astray after that. Thereupon Umar said: Verily Allah's Messenger (ﷺ) is deeply afflicted with pain. You have the Qur'an with you. The Book of Allah is sufficient for us. Those who were present in the house differed. Some of them said: Bring him (the writing material) so that Allah's Messenger (ﷺ) may write a document for you and you would never go astray after him And some among them said what 'Umar had (already) said. When they indulged in nonsense and began to dispute in the presence of Allah's Messenger (ﷺ), he said: Get up (and go away) 'Ubaidullah said: Ibn Abbas used to say: There was a heavy loss, indeed a heavy loss, that, due to their dispute and noise. Allah's Messenger (ﷺ) could not write (or dictate) the document for them.
وَحَدَّثَنِي مُحَمَّدُ بْنُ رَافِعٍ، وَعَبْدُ بْنُ حُمَيْدٍ، - قَالَ عَبْدٌ أَخْبَرَنَا وَقَالَ ابْنُ رَافِعٍ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، - أَخْبَرَنَا مَعْمَرٌ، عَنِ الزُّهْرِيِّ، عَنْ عُبَيْدِ اللَّهِ بْنِ عَبْدِ اللَّهِ بْنِ عُتْبَةَ، عَنِ ابْنِ عَبَّاسٍ، قَالَ لَمَّا حُضِرَ رَسُولُ اللَّهِ صلى الله عليه وسلم وَفِي الْبَيْتِ رِجَالٌ فِيهِمْ عُمَرُ بْنُ الْخَطَّابِ فَقَالَ النَّبِيُّ صلى الله عليه وسلم ‏"‏ هَلُمَّ أَكْتُبْ لَكُمْ كِتَابًا لاَ تَضِلُّونَ بَعْدَهُ ‏"‏ ‏.‏ فَقَالَ عُمَرُ إِنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَدْ غَلَبَ عَلَيْهِ الْوَجَعُ وَعِنْدَكُمُ الْقُرْآنُ حَسْبُنَا كِتَابُ اللَّهِ ‏.‏ فَاخْتَلَفَ أَهْلُ الْبَيْتِ فَاخْتَصَمُوا فَمِنْهُمْ مَنْ يَقُولُ قَرِّبُوا يَكْتُبْ لَكُمْ رَسُولُ اللَّهِ صلى الله عليه وسلم كِتَابًا لَنْ تَضِلُّوا بَعْدَهُ ‏.‏ وَمِنْهُمْ مَنْ يَقُولُ مَا قَالَ عُمَرُ ‏.‏ فَلَمَّا أَكْثَرُوا اللَّغْوَ وَالاِخْتِلاَفَ عِنْدَ رَسُولِ اللَّهِ صلى الله عليه وسلم قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ قُومُوا ‏"‏ ‏.‏ قَالَ عُبَيْدُ اللَّهِ فَكَانَ ابْنُ عَبَّاسٍ يَقُولُ إِنَّ الرَّزِيَّةَ كُلَّ الرَّزِيَّةِ مَا حَالَ بَيْنَ رَسُولِ اللَّهِ صلى الله عليه وسلم وَبَيْنَ أَنْ يَكْتُبَ لَهُمْ ذَلِكَ الْكِتَابَ مِنِ اخْتِلاَفِهِمْ وَلَغَطِهِمْ ‏.‏
Reference : Sahih Muslim 1637 c
In-book reference : Book 25, Hadith 31
USC-MSA web (English) reference : Book 13, Hadith 4016
  (deprecated numbering scheme)