Mutual exclustion in terminate process