Several classes rely on other classes' and variables' presence during
their destruction. The most prominent case is various sub-classes of
mm_io_c using the debugging facilities, e.g. debugging_c. Therefore
debugging_c must still work when mm_io_c instances are closed.
Otherwise access to invalid memory will occur (a use after free),
e.g. by the destructor of mm_io_c calling debugging_c::operator()
accessing a std::vector or std::unordered_map that's already been
destructed.
For mkvmerge this means that ::exit() must not be called before all
instances of mm_io_c have been closed. This commit moves in that
direction by explicitly closing several resources stored in global
variables in the proper order before calling ::exit().
Fixes the following cases of #1780:
explorer🆔000000,sig:11,src:000000,op:flip1,pos:1
explorer🆔000001,sig:11,src:000000,op:flip1,pos:2
explorer🆔000608,sig:06,src:001761,op:int8,pos:135,val:-128
explorer🆔000738,sig:11,src:002531,op:int32,pos:126,val:be:+1
explorer🆔000740,sig:06,src:002531,op:ext_AO,pos:99