0.9.17.2: fix two potential GC deadlocks
* Dying threads used to grab session and all-threads locks
with GC inhibited, which was bad:
1. T1 has the lock, GC not inhibited
T2 in HANDLE-THREAD-EXIT waiting for the lock, GC inhibited
2. GC is triggered
3. T1 stopped while holding the lock
T2 deadlocks waiting for T1 to release the lock.
* Mark threads dead while holding the *ALL-THREADS-LOCK*, so that
(unless (thread-alive-p th)
(assert (not (member th (list-all-threads)))))
cannot fail.
* Since dying threads can now trigger GCs, don't run after-gc hooks
and finalizers if the thread has been marked as dead.
* Move all thread cleanup logic to HANDLE-THREAD exit.