modified code to actually stop when maintenance mode is on