Coding Problem

BlitzPlus Forums/BlitzPlus Beginners Area/Coding Problem

I have been screwing around with this function far too long,
I've used it in other programs and in this one the problem
is that it says "End Select without Select". Here's my code
Function StartEruP()
MainMenu=CreateWindow("Main Menu",300,300,400,500,main,15)
Ev=WaitEvent()
Es=EventSource()
Repeat
Select Es
Case MainMenu
If Ev=$803 Then
Blah=Proceed("Do you really want to quit?")
If Blah=1 Then
End 
Else
If Blah<>1 Then
Notify("Find out what you want next time")
EndIf
EndIf
End Select 
Until KeyDown(1)
End 
End Function
StartERuP()
End 

On the other program it works, but when ever I attempt
to move the window it moves, but the program starts to
go on strike.