You can stop a task with the stop statement.
The stop statement is only supported if you are running the enhanced NBC/NXC firmware on your NXT.