How to detect a glut close window event?

Hi.
Can someone tell me how to detect that a glut window is being closed so that i can process some commands before exiting. I have allocated memory dynamically to objects using new , which i want to deallocate before the program exits.

Thanks.

Take a look at this thread – I think it’s got what you’re looking for.