The push button is constructed in this example for closing the program. We use an exception named ProgramExit for this purpose. (Note that in C++ an empty class is used for naming an exception.) In turn, our handler throws the exception to break the normal flow of execution. Since handling the exception means terminating the program, we write the catch statement in the main function after the glutMainLoop call.

Note that GLUI passes our handler the integer value that represents the id of the control element. However, as seen in the code, we are not using this value.