Have you tried the command “StopAllTasks()”? It stops all tasks in the program, including task main.
To restart the program, you would need to cycle the power on the cortex.
If you want to keep the main task running and you have included “Vex_Competition_Includes.c”, you can use allMotorsOff. It just turns off all the motors, butt still keeps all the tasks and loops running how they were. For Example,