Fixes crashes on detach by walking the takeover_table on exit and setting the context back to the interruption point for threads that we tried to attach but were never scheduled.
Also adds a revert point in thread_attach_setup() if init_apc_go_native() is set, for threads that are scheduled during detach.
Tested on the tool.drcacheoff.burst_static test with VS2017, which will soon become a regression test when we move to VS2017 (#2924 (closed)).
Fixes #4053 (closed)