Fixed handling of timer callback routines when the thread owning the
callback terminates.

diff --git a/server/thread.c b/server/thread.c
index 09ad63b..eba63e1 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -554,6 +554,7 @@
 
     /* cancel a possible previous APC with the same owner */
     if (owner) thread_cancel_apc( thread, owner, system );
+    if (thread->state == TERMINATED) return 0;
 
     if (!(apc = mem_alloc( sizeof(*apc) + (nb_args-1)*sizeof(apc->args[0]) ))) return 0;
     apc->prev    = queue->tail;