FIXED: reorganise termination.  We now use the new hook PL_exit_hook() to
call qtApp->quit() and wait for that to do its job.  The only failure I
found now is to start xpce and call halt/0 from another thread than the
main one.