detach resource 'sem' when a task is terminated.