Hello,

In message "How to completely terminate a WIN32OLE Excel object?"
    on 07/05/26, Sven Suska <sven715rt / suska.org> writes:

> When the Ruby process is terminated (after sleep), the
> Excel process will also terminate.
> 
> So, what's the proper way to handle this?
> 
> I've found the WIN32OLE.ole_free method, but they say
> that it is for debugging only.

I am not sure, but it seems to me because of GC behavior.
I tested your script using Foo class instead of WIN32OLE.
And I've got same result as WIN32OLE.

--- code starts ---
class Foo
  def initialize(arg)
    @arg = arg
  end
  def Quit
  end
end

def puts_win32ole_objects
  res = []
  ObjectSpace.each_object do |o|
    res << o if o.is_a? Foo
  end
  puts res.inspect
end

puts_win32ole_objects  # --> empty
xl = Foo.new('Excel.Application')
puts_win32ole_objects  # --> one object
xl.Quit
xl = nil
GC.start  # anything else I could do???
puts_win32ole_objects  # --> the object is still there
sleep 5
puts_win32ole_objects  # --> the object is still there  
--- code end ---

The Excel process is terminated when the WIN32OLE object is GCed.
But in this case, the WIN32OLE object is not GCed, so  the Excel 
process is not terminated.

I recommend that you do not use WIN32OLE#ole_free(See following REMARK!).
But if you want to terminate the process before the WIN32OLE object GCed, 
you can use WIN32OLE#ole_free.

REMARK!
  WIN32OLE#ole_free terminates the Excel process but
  the WIN32OLE object is not GCed.
  You should not access the WIN32OLE object after WIN32OLE#ole_free
  called.
 
  Regards
  Masaki Suketa