How to stop a TimerFunction callback?

I use the TimerFunction below to animate spiral (make it rotate). How can I stop the TimerFunction?? I used a for-loop to test if it can be called only several times, but it did not work.

void TimerFunction(int value)
{
glRotatef(5.0,0.0f,0.0f,1.0f);
glutPostRedisplay();
glutTimerFunc(20, TimerFunction, 1);
}

According to GLUT spec - There is no support for canceling a registered callback. Instead, ignore a callback based on its value parameter when it is triggered.

The GLUT docs can be found http://www.opengl.org/resources/libraries/glut/spec3/spec3.html

Well, you can always try glutTimerFunc(20, NULL, 0);
That way the callback has no function to call to.
I think this is the best way to cancel callbacks. But you can’t disable important callbacks like glutDisplayFunc (reasonably)

Humm…
But if there is no way to stop the callback, how can I stop an animation? I really don`t get the clue yet. I basically rotate a coordinate system, every x milliseconds. But at a certain point I want it to stop rotating. How would I do this then? Can you post some lines of code please…

it’s been a while I didn’t program in glut… Let’s have a try:

int do_i_have_to_rotate = 1;
[...]
void TimerFunction(int value)
{
   glRotatef(5.0,0.0f,0.0f,1.0f);
   glutPostRedisplay();
   
   if (do_i_have_to_rotate)
      glutTimerFunc(20, TimerFunction, 1);
}

Simply update the variable ‘do_i_have_to_rotate’ when you know what to do. You can make another function with another glut timer that will have to take care of managing the variable.
I hope this is not wrong…