Thanks for looking.
I copied this part of the code into the while loop and it's working now. I guess I can live with having to hold the button for 2 seconds to stop it.
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{
motOn = !motOn; //motOn is boolean variable for switch on/off
}
lastButton = currentButton;
digitalWrite(SLEEP, motOn); //set SLEEP pin to value of motOn variable