This line is the problem
if dteEnd=Now() then
Only if dteEnd is exactly the same as Now() (to the millisecond) will it be able to step into the controller section and head towards the exit do, it doesn't and goes into a recursive loop (back into the sleep function)
Try this instead:
do While dteEnd>=Now()
if dteEnd>=Now() then
if controller(path,filesCountMust)=true then
exit do
else
Sleep intSeconds,path,filesCountMust
end if
end if
loop