Fix potential deadlocks in terminator