Fix potential deadlock.