This adds a test for thread cleanup. It tests two things:
1. Thred exit in general works, both through return as well as
DkThreadExit.
2. If there's a thread limit, like on SGX, it tests that after a thread
has finished it no longer counts against the limit (currently
broken, see issue #517).