darwin: Explicitly cleanup cached devices during the last libusb_exit()
Deferring the cached devices cleanup until the "destructor" function is
called makes it appear as though libusb is leaking memory, especially if
heap allocations are analyzed after calling libusb_exit(). It can also
lead to devices staying on the list longer than they should, as seen by
the following sequence of events:
libusb_init() <-- init_count is 0, async thread is started
devices_scan_devices() <-- enumerates devices
libusb_exit() <-- init_count is 0, async thread is stopped
[one or more devices disconnected]
Because the async thread is stopped when device(s) are disconnected in
the above sequence, the disconnection event(s) will not be processed and
thus darwin_devices_detached() will not be called and the list will have
one or more stale entries until the "destructor" function is finally
called.
Address both of these shortcomings by cleaning up the cached devices
list after stopping the async thread.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>