stop a previuos run of a task in tasker
That's what Tasker offers by default: if a task is already running, either the new instance stops immediately (default IIRC) or the already running one gets stopped. Should be in the advanced setting of the task:



Tap the settings button (bottom right in the screenshot) to open this screen, then chose in the drop-down box for "Collision Handling":


Abort New Task: The task won't be executed while another instance is already running
Abort Existing Task: If there's already an instance running, abort that and run the new one
Run Both Together: Let them collide, no matter how often