Avoid an infinite loop in InitRootHandlers destructor

If there is a problem with the list of open files from ROOT such that casting an element to TFile fails the code no longer gets stuck in an infinite loop.
The problem actually happened in the Tier 0 probably due to a threading problem in ROOT.
Merge pull request #6213 from Dr15Jones/avoidInfiniteLoopInRootInitHandler

Avoid an infinite loop in InitRootHandlers destructor