The Prophet ﷺ said, "When one of you grows drowsy during the prayer, let him leave it and sleep."
حدثنا عفان حدثنا وهيب حدثنا أيوب عن أبي قلابة
أن النبي ﷺ قال إذا نعس أحدكم وهو في الصلاة فلينصرف فلينم
Its isnad is sahih, mentioned previously at 12459.