When the alarm goes off, I always end up turning it off while still asleep.

Literal

Alarm-clock [subj-が] rings [when-と], always sleeping [while-うちに] stop [completion-てしまう] [explanatory-のです].

~うちに ('while still in a state') captures the window during which the action occurs — here, while still asleep. ~てしまう marks the action as inadvertent or regrettable. ~と is the habitual-condition 'whenever.' のです explains the pattern.