title: boost::interprocess::scoped_lock not unlocking the mutex
body: <p>I use a boost named_mutex to check if there is already a mutex with the corresponding name,  and if it is to halt the program because i want to stop other instances of my app to be ran.</p>
  <p>I do this. <strong>at the beginning</strong> of the program:</p>
  <pre><code>try {
      boost::interprocess::named_mutex mutex_to_lock(boost::interprocess::open_only, &quot;scilock&quot;);
      exit(0);
  } catch (...) {
      boost::interprocess::named_mutex mutex_to_lock(boost::interprocess::create_only, &quot;scilock&quot;);
      boost::interprocess::scoped_lock locking(mutex_to_lock);
  }
  
  *rest of the program...*
  </code></pre>
  <p>It tries to open a mutex first, if it exists, it exits, and if one doesn't exists it throws an exception meaning that we can go ahead and create one. I use a scoped_lock on the mutex so I don't have to manage the unlocking of it (<strong>it should unlock even if the app crashes</strong>), however it does not unlock it at all. the mutex remains closed after the program ends.</p>
  <p>i have tried using named_recursive_mutex, even though I don't think it helps with anything</p>
  <p>i have also tried this format:</p>
  <pre><code>    boost::interprocess::named_mutex mutex_to_lock(boost::interprocess::open_or_create, &quot;scilock&quot;);
      boost::interprocess::scoped_lock locking(mutex_to_lock, boost::interprocess::try_lock);
      if (!lock) // if it didnt manage to lock (meaning that probably it is already locked)
          exit(0);
  </code></pre>
  <p>but overall same results.</p>
  <p>If it helps with anything, I am using Fedora 36, with boost 1.76</p>
  <p>Minimal reproducible example:</p>
  <pre><code>#include &lt;chrono&gt;
  #include &lt;iostream&gt;
  #include &lt;thread&gt;
  
  #include &lt;boost/interprocess/sync/named_mutex.hpp&gt;
  #include &lt;boost/interprocess/sync/scoped_lock.hpp&gt;
  
  int main() {
    boost::interprocess::named_mutex mutex_to_lock(
        boost::interprocess::open_or_create, &quot;sci&quot;);
    boost::interprocess::scoped_lock locking(mutex_to_lock,
                                             boost::interprocess::try_to_lock);
  
    if (!locking) {
      printf(&quot;exiting..&quot;);
      exit(0);
    }
  
    std::this_thread::sleep_for(std::chrono::seconds(5));
  
    return 0;
  }
  </code></pre>
  <p>The mutex is not being unlocked on app termination, which is not what i want. I want it closed even if the program is being terminated</p>