This fixes shutdown race bug that CoreCLR port reintroduced.
Basically the fix needed some Appdomain APIs that were probably
not in .NET Core 1.0 so they were removed. However they are
back in .NET Core 2.0 so it is trivial to simply 'do the right thing', and
put the shutdown logic back.
See comment in front of DisposeOnShutdown for more.
Commit migrated from https://github.com/dotnet/coreclr/commit/
f4b36aa998ead4dddea6c29de6ac0a393fb138a8
if (!s_EventSourceShutdownRegistered)
{
s_EventSourceShutdownRegistered = true;
+ AppDomain.CurrentDomain.ProcessExit += DisposeOnShutdown;
+ AppDomain.CurrentDomain.DomainUnload += DisposeOnShutdown;
}