Winole prob or not

hello
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 = WIN32OLE.new(“Broker.Application”)
application.quit
puts “called to close”
end

Everything

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

  end

}