How to exit or stop OpenGL ??

I start OpenGL with glutMainLoop();

How can one exit OpenGL or stop OpenGL within the routine. My code is written in C++.

Reson for my question are unexpected crashes, when I just close the Windows.

Means, I am looking for a save exit out of the program…

Closing the (main) window is the normal way to exit a glut application, it does not have any nice friendly shutdown feature.

But your application should not crash because of this, run the debugger and find out where it crashes, it may be something in your own code.

Mikael