fix Issue 10976 - thread_joinAll after main exit performed too late

- Move thread_joinAll out of rt_term and call it
  immediately after exiting from main instead.
- Make it an error to call rt_term when other threads
  are still running.
- As a side effect it will be called before `static ~this()`
  of the main thread is run.