jrep: Fix locking around the exit condition for multithreading.