If the mutex is not locked the notification might be missed and the thread will not join. I never encountered that behavior.
https://en.cppreference.com/w/cpp/thread/condition_variable:
Even if the shared variable is atomic, it must be modified while owning the mutex to correctly publish the modification to the waiting thread.