So I am testing out pbp and am trying to get an led to fade on, stay on, then fade off. Here is my current code

Code:
STARTMAIN:
if button=0 then
    For Duty=0 to 255 Step 1
        PWM LED4,Duty,Cycle
    Next
    led4=1
    pause 1000
    For Duty=255 to 0 Step -1
        PWM LED4,Duty,Cycle
    Next
    LED4=0

endif
LED4=0
GOTO STARTMAIN
What happens is that when I press the button, the led fades on, then turns off for a second, then fades off. Why is this happening?