Merge pull request #947 from klickverbot/run-tls-dtors

Issue 13414 - Static destructors not called correctly with dynamic loading
Merge pull request #992 from MartinNowak/2.066

cherry-picks for 2.066.1