diff --git a/src/quick-lint-js/io/pipe-writer.cpp b/src/quick-lint-js/io/pipe-writer.cpp index 4a0c93b72..ddfdf0898 100644 --- a/src/quick-lint-js/io/pipe-writer.cpp +++ b/src/quick-lint-js/io/pipe-writer.cpp @@ -35,8 +35,11 @@ Background_Thread_Pipe_Writer::Background_Thread_Pipe_Writer( } Background_Thread_Pipe_Writer::~Background_Thread_Pipe_Writer() { - this->stop_ = true; - this->data_is_pending_.notify_one(); + { + std::unique_lock lock(this->mutex_); + this->stop_ = true; + this->data_is_pending_.notify_one(); + } this->flushing_thread_.join(); }