Fix concurrency issue when garbage collecting nodes.