How would I stop a npc mid pathfinding?

I want to stop a npc mid pathfinding but how would I do that?

Code:

local GameInProgress = game.ServerStorage.GameValues:WaitForChild("GameInProgress")
local CollectionService = game:GetService("CollectionService")
local PathFindingService = game:GetService("PathfindingService")

local NpcsCollection = CollectionService:GetTagged("Npcs")

local path = PathFindingService:CreatePath()


local function setupNpcs(Npcs)
	GameInProgress.Changed:Connect(function()
		if GameInProgress.Value == true then
			task.wait(3)
			repeat
			local RandomObj = Random.new()
			local Availablewaypoints = workspace.School.Npcwaypoints:GetChildren()	
			local ChoosenWaypoint = Availablewaypoints[RandomObj:NextInteger(1,#Availablewaypoints)]
			task.wait(0.2)	
			local function getpath(destination)
				local pathparams = {
					["AgentHeight"] = 5.37,
					["AgentRadius"] = 2,
					["AgentCanJump"] = true,
				}	
				local path = PathFindingService:CreatePath(pathparams)	
					
				if GameInProgress.Value == true then	
				path:ComputeAsync(Npcs.HumanoidRootPart.Position, destination.Position)		
				end		
						
				return path	
			end
				
			local function walkTo(destination)
				local path = getpath(destination)
					for index, waypoint in pairs(path:GetWaypoints()) do
						Npcs.Humanoid:MoveTo(waypoint.Position)
						
						path.Blocked:Connect(function()
							local path = getpath(destination)
							walkTo(ChoosenWaypoint)
						end)
						
						if waypoint.Action == Enum.PathWaypointAction.Jump then
							Npcs.Humanoid.Jump = true
						end
						
						Npcs.Humanoid.MoveToFinished:Wait()
					end			
				end	
				
			if Npcs:FindFirstChild("Occupied") then
				if Npcs:FindFirstChild("Occupied").Value == false then		
					print(Npcs.Name)		
					walkTo(ChoosenWaypoint)
				end		
			end
				
				Npcs:FindFirstChild("Occupied").Changed:Connect(function()
					if Npcs.Occupied.Value == true then
						print(Npcs.Name)
						walkTo(Npcs.HumanoidRootPart)
					end		
				end)
				
					
			until GameInProgress.Value == false
		end
	end)
end


local function NpcAdded(Npcs)
	setupNpcs(Npcs)
end

-- Connect existing Npcs
for _, model in pairs(NpcsCollection) do
	setupNpcs(model)
end

-- Connect new Npcs
CollectionService:GetInstanceAddedSignal("Npcs"):Connect(NpcAdded)

Just call MoveTo to the current NPC’s position?

npc.Humanoid:MoveTo(npc.Position)

Okay I will try this
(30 words requirement)

go to half of #Waypoints/2 position

It worked sometimes
(30 words requirement)

You need to make sure your pathfinding script, or whatever is controlling the MoveTo, is stopped before calling it.

How do I force stop a MoveTo before the target is reached?

I can’t help you without seeing your code.

Posted my code
(30 words requirement)

You can try checking if a variable is true while your NPC is walking to waypoints, and if so, break the loop.