Smartphone use among medical students has become pervasive. While existing literature links excessive smartphone use to poor sleep quality, the specific behavioral pattern most strongly associated with sleep disruption remains insufficiently characterized. This study investigated whether the timing of smartphone cessation relative to sleep onset is more strongly associated with poor sleep quality than total daily screen time among medical students in Punjab, Pakistan, and examined the moderating role of exam period status. A cross-sectional anonymous online survey was conducted among medical students across Punjab, Pakistan (May 2026). Sleep quality was assessed using items informed by Pittsburgh Sleep Quality Index (PSQI) response formats. Descriptive statistics, chi-square tests, and binary logistic regression were applied to 369 eligible responses, reported in accordance with STROBE guidelines. Of 369 respondents (49.9% female, 48.2% male), 74.8% reported using smartphones 6 or more hours daily and 61.2% used their smartphone until falling asleep. Overall, 75.7% reported poor sleep quality. Students using smartphones until sleep onset had 95.1% poor sleep quality compared to 44.8% in those who ceased use before sleeping (p