Winole prob or not

i am chcking if i have the app amibroker instance running. if it is, i
want to close it smoothly. however i land into a ole problem here. it
only quits 1 instance at a single run. for eg. if i i have 3
instances running and i execute the following script. it will close 1
instance leaving 2 open. if i run it again, it will close another
instance leaving 1 open. is it a win32ole prob or amibroker prob.

def closeAB
application =“Broker.Application”)
puts “called to close”

Everything { |p|
if(p.caption ==“Broker.exe”) then
# close amibroker
puts " found ab"