Mega1280 Timer Interrupt question

Hi,
I have a simple stepper motor application (within a much larger project) that runs a motor until it is stopped by end switch.

My question is:
what is the corrector best way to stop the motor when the end switch is met, and enable when a new request comes (Not by number of steps.

I did not find any 'enable' / 'disable' bit in the Atmel AVR interrupt registers' descriptions.
(I know I can do it by changing the prescaler, but this is not a clean way).

Here is a simplified snippet of my code:

void setup()
{
.
.
TCCR3A = 0; // reset entire TCCR3A register to 0
TCCR3B = 0; // reset entire TCCR3A register to 0
OCR3A = 1000; //Output Compare Register 3A: 16,000,000 / 1000 / 8 / 2 = 1kHz
TCCR3B |= (1 << 3);// WGM32 Wave Generation Mode
TCCR3B |= (1 << 1); //CS31 Set CS#1 bit for 8 prescaler for timer 3
TIMSK3 |= (1 << 1); //OCIE1A
.
.
}

void motorRight()
{
digitalWrite(stepDirection, HIGH); //Going Right

while (digitalRead(rightSwitch) == 1 )

{ //Wait for switch closure}
}

void motorLeft()
{
digitalWrite(stepDirection, LOW); //Going Left

while (digitalRead(leftSwitch) == 1 )

{ //Wait for switch closure}
}

what is the corrector best way to stop the motor when the end switch is met, and enable when a new request comes (Not by number of steps.

And enable what? What does the new request look like, if it is not a number of steps? What does all the manipulation stuff do, anyway?

Here is a simplified snippet of my code:

That hasn't a hope in hell of compiling. Quit wasting our time. Post your real code.

Sorry I forgot to show the interrupt handler.
Here it is again, with the handler, and simplified

The question is: There will be an interrupt each 1 mSec that will drive one step.
When the end switch closes, I want the motor to stop, but I can not find a way to hold or disable / enable the interrupt of its handler.

void setup()
{
.
.
TCCR3A = 0; // reset entire TCCR3A register to 0
TCCR3B = 0; // reset entire TCCR3A register to 0
OCR3A = 1000; //Output Compare Register 3A: 16,000,000 / 1000 / 8 / 2 = 1kHz
TCCR3B |= (1 << 3);// WGM32 Wave Generation Mode
TCCR3B |= (1 << 1); //CS31 Set CS#1 bit for 8 prescaler for timer 3
TIMSK3 |= (1 << 1); //OCIE1A
.
.
}

//The interrupt handler:
ISR(TIMER3_COMPA_vect) //Timer3 is used for the stepper motor speed control.
{
motorRight(); //Run one step per each interrupt.
}

void motorRight()
{
digitalWrite(stepDirection, HIGH); //Setting direction Going Right
//Toggle the motor pin on/off for square signal.
digitalWrite(stepperStepPin, !digitalRead(stepperStepPin));
while (digitalRead(rightSwitch) == 1 )

{ //Wait for switch closure = 0
//How you stop the rotation? (The handler)?
}

}

(I know I can do it by changing the prescaler, but this is not a clean way).

Why is this not clean? Setting the three CS/prescaler bits to 000 will stop the timer.

The way you have your timer configured, with only CS31 set, the following should do it

TCCR3B &= ~(1 << 1);

Alternatively, in the interrupt handler, read the state of the limit switch first. If not pressed, step.

Thanks cattledog and PaulS.
Both solutions answer my question.

cattledog - can you please elaborate the operation of TCCR3B &= ~(1 << 1);?

x &= ~ y ;

means clear all the bits in x that are set in y.
Its the converse of

x |= y ;

which sets bits in x that are set in y

Thx