Index: soft/giet_vm/giet_kernel/ctx_handler.c
===================================================================
--- soft/giet_vm/giet_kernel/ctx_handler.c	(revision 696)
+++ soft/giet_vm/giet_kernel/ctx_handler.c	(revision 697)
@@ -30,9 +30,13 @@
     static_scheduler_t* psched = (static_scheduler_t*)_get_sched();
 
+    // pretend the task to kill is scheduled (required for sys_handler calls)
+    unsigned int cur_task = psched->current;
+    psched->current = ltid;
+
     // release private TTY terminal if required
     if ( psched->context[ltid][CTX_TTY_ID] < NB_TTY_CHANNELS )
     {
-        psched->context[ltid][CTX_TTY_ID] = 0xFFFFFFFF;
         _sys_tty_release();
+        psched->context[ltid][CTX_TTY_ID] = -1;
     }
 
@@ -40,6 +44,6 @@
     if ( psched->context[ltid][CTX_TIM_ID] < NB_TIM_CHANNELS )
     {
-        psched->context[ltid][CTX_TIM_ID] = 0xFFFFFFFF;
         _sys_tim_release();
+        psched->context[ltid][CTX_TIM_ID] = -1;
     }
 
@@ -47,6 +51,6 @@
     if ( psched->context[ltid][CTX_NIC_RX_ID] < NB_NIC_CHANNELS )
     {
-        psched->context[ltid][CTX_NIC_RX_ID] = 0xFFFFFFFF;
         _sys_nic_release( 1 );
+        psched->context[ltid][CTX_NIC_RX_ID] = -1;
     }
 
@@ -54,7 +58,10 @@
     if ( psched->context[ltid][CTX_NIC_TX_ID] < NB_NIC_CHANNELS )
     {
-        psched->context[ltid][CTX_NIC_TX_ID] = 0xFFFFFFFF;
         _sys_nic_release( 0 );
-    }
+        psched->context[ltid][CTX_NIC_TX_ID] = -1;
+    }
+
+    // restore scheduled task
+    psched->current = cur_task;
 
     // set NORUN_MASK_TASK bit
Index: soft/giet_vm/giet_kernel/irq_handler.c
===================================================================
--- soft/giet_vm/giet_kernel/irq_handler.c	(revision 696)
+++ soft/giet_vm/giet_kernel/irq_handler.c	(revision 697)
@@ -206,7 +206,7 @@
 ////////////////////////////////////////////
 void _ext_irq_release( unsigned int isr_type,
-                       unsigned int isr_channel,
-                       unsigned int wti_index )
-{
+                       unsigned int isr_channel )
+{
+    unsigned int wti_id;        // allocated WTI mailbox index in XCU
     unsigned int irq_id;        // external IRQ index in PIC (input)
 
@@ -230,4 +230,17 @@
     }
 
+    // find WTI index
+    static_scheduler_t*  psched = (static_scheduler_t*)_get_sched();
+    for ( wti_id = 0 ; wti_id < 32 ; wti_id++ )
+    {
+        if ( psched->wti_vector[wti_id] == (isr_channel<<16 | isr_type) )
+            break;
+    }
+    if ( wti_id == 32 )
+    {
+        _printf("\n[GIET ERROR] in _ext_irq_release() : isr not found\n");
+        return;
+    }
+
     // desactivates dynamically allocated PIC entry
     irq_id = _ext_irq_index[isr_type][isr_channel];
@@ -235,7 +248,7 @@
 
     // releases dynamically allocated WTI mailbox
-    if      ( wti_index == p +   NB_PROCS_MAX ) _wti_alloc_one[x][y][p] = 0;
-    else if ( wti_index == p + 2*NB_PROCS_MAX ) _wti_alloc_two[x][y][p] = 0;
-    else if ( wti_index == p + 3*NB_PROCS_MAX ) _wti_alloc_ter[x][y][p] = 0;
+    if      ( wti_id == p +   NB_PROCS_MAX ) _wti_alloc_one[x][y][p] = 0;
+    else if ( wti_id == p + 2*NB_PROCS_MAX ) _wti_alloc_two[x][y][p] = 0;
+    else if ( wti_id == p + 3*NB_PROCS_MAX ) _wti_alloc_ter[x][y][p] = 0;
     else
     {
Index: soft/giet_vm/giet_kernel/irq_handler.h
===================================================================
--- soft/giet_vm/giet_kernel/irq_handler.h	(revision 696)
+++ soft/giet_vm/giet_kernel/irq_handler.h	(revision 697)
@@ -96,6 +96,5 @@
 
 extern void _ext_irq_release( unsigned int isr_type,
-                              unsigned int isr_channel,
-                              unsigned int wti_index );
+                              unsigned int isr_channel );
 
 ///////////////////////////////////////////////////////////////////////////
Index: soft/giet_vm/giet_kernel/sys_handler.c
===================================================================
--- soft/giet_vm/giet_kernel/sys_handler.c	(revision 696)
+++ soft/giet_vm/giet_kernel/sys_handler.c	(revision 697)
@@ -797,4 +797,7 @@
 int _sys_tty_release()
 {
+    // release WTI mailbox
+    if ( USE_PIC ) _ext_irq_release( ISR_TTY_RX , _get_context_slot( CTX_TTY_ID ) );
+
     // release one TTY terminal
     _atomic_increment( &_tty_channel_allocator , 0xFFFFFFFF );
