Introduce EndOfProcessCleanups rather than subverting CloseFiles

Apply the same modifications than in TUnixSystem, preventing a crash when selecting "Quit ROOT" from the menu of a TCanvas