closing a glut window from within my code?

Im having trouble working out how to do this?
I have a glut window which is being opened from within my code (a simulation of sorts) this window then displays the required output etc, but then how do i close this window when im done with it, and cause the program control flow to return to the code which first created the glut window?
All ive managed so far is either for the window just to stay, and program flow not to return to my code, or, for the whole program to quit out, both of which are not acceptable. So any help is greatly appreciated

Ta

do a search on here, there is a hacked function that allows you to exit the main loop without killing the whole prog.

There is a “seriously modified” version available from my website. Check out:
http://www-users.york.ac.uk/~rpf1/glut.html

Hope it helps.

Rob.