glut close windows on OSX

I am using GLUT on OSX (10.6.x) from a C++ program. I want to call a function in the program as a callback when the glut window is destroyed by clicking on “X”. I don’t find a “glutCloseFunc” or glutWMCloseFunc in my GLUT implementation. How can I get this callback function to be called?

Any help is appreciated. Thanks in advance.

Is switching GLUT implementations an option for you? Using openglut or freeglut instead of what you are using currently is perhaps the easiest solution.