closing 1 of 2 windows

BlitzMax Forums/BlitzMax Programming/closing 1 of 2 windows

I know this has been posted before but I can't find it with the new search.

If I have two windows open, how do I get only one to close?

I've tried something like this:

While Not done
			PollEvent()
			
			Select EventID()
				Case EVENT_WINDOWCLOSE   
					If EventSource() = sWindow 
						done = True 
						FreeGadget(sWindow)
					EndIf 
endselect 

but both windows close when I click the X to close "swindow", even though one is named window and one is named swindow.