Send ThreadEnd after clearing ThreadGroup.

The removal of a thread from it's thread group does cause managed code
to execute so it could cause additional events to trigger in agents,
potentially causing deadlocks. This changes where the event is
triggered to put it after the thread has been removed from its group.

Test: ./test.py --host -j50
Bug: 67104807

Change-Id: I53f53b2823835a9629842fb5c22079b3e42042d5
20 files changed