Hi Muhammad,
You are iterating from the array's start to its end. Thus, the potential problem is that OS/TestComplete may reassign the indexes of the running IE processes and this will result in script error.
I would rewrite your function either:
Function CloseAllBrowser
IExplore = Sys.FindAllChildren("ProcessName","iexplore",2)
If UBound(IExplore)>=0 Then
For i = UBound(IExplore) to LBound(IExplore) Step -1 ' <== iterate from top to bottom
IExplore(i).Terminate
Next
End If
End Function
or (untested, off-top of my head)
Function CloseAllBrowser
Do
IExplore = Sys.WaitProcess("iexplore", -1, 200)
If (IExplore.Exists) Then
IExplore.Close
IExplore = Sys.WaitProcess("iexplore", -1, 200)
Else
Exit Do
End If
Loop
End Function