Fix coverity report (unchecked return and missing initialization)
Reduce the risk of the files or sockets being closed after the end of 'main' (or more exactly before the library start being unloaded) by calling CloseFiles and ResetGlobals in the destructor of the TApplication (which is in most cases on the stack of the main function)

git-svn-id: http://root.cern.ch/svn/root/trunk@48219 27541ba8-7e3a-0410-8455-c3a389f83636
(cherry picked from commit 84dfc99672b0eaa836d173dc4171dffcc19742ea)
Extend (subvert!) TROOT::CloseFiles to also delete the other active user objects held in TROOT ; for example this allow the earlier deletion of outstanding TBrowsers object, allowing their destructor to use a fully functional interpreter ; this fixes <http://savannah.cern.ch/bugs/?99193>

git-svn-id: http://root.cern.ch/svn/root/trunk@48220 27541ba8-7e3a-0410-8455-c3a389f83636
(cherry picked from commit ae57174d1b1ffba66cbbecfef77ee55365c14127)
Also call TROOT::CloseFiles as a atexit function.  This reduces the risk of problem when ::exit is called explicitly.  However this solution still requires at least one TApplication to be created and since atexit (on linux/macos) are in order, this is still technically too late.  The library that are loaded dynamically (gSystem->Load, dlopen) will be unloaded before the atexit installed by TApplication (at the start of the main).  What we really need is to call exactly after the end of the main and before the first library (with a dictionary) is unloaded [which we could do if (and only if) we know how to cheaply know that the library is being unloaded after main

git-svn-id: http://root.cern.ch/svn/root/trunk@48236 27541ba8-7e3a-0410-8455-c3a389f83636
(cherry picked from commit 0f0289597deefab376512a9986885b1dbeecdbf5)
Add missing header

git-svn-id: http://root.cern.ch/svn/root/trunk@48237 27541ba8-7e3a-0410-8455-c3a389f83636
(cherry picked from commit 8fc631bf874b961a3087fa1105c57b65aafbeb0c)
Remove from closeFiles the deletion that are either too early or inaccurate (fSpecials does not own its content)

git-svn-id: http://root.cern.ch/svn/root/trunk@48248 27541ba8-7e3a-0410-8455-c3a389f83636
(cherry picked from commit 43ed8fa6a1a8eef87948363cfc67c4f192bfbf27)
Introduce EndOfProcessCleanups rather than subverting CloseFiles.

This allows to separate the end of process action from just
closing the files (used by pyroot).

See commit ae57174d1b1ffba66cbbecfef77ee55365c14127
Fix order of deletion TROOT destructor and EndOfProcessCleanups.

Some objects (TParallelCoord) manipulate global objects (TStyles)
in their destructor.  Reorder the deletion of the global object
to avoid conflicts.