<p>When running PHP in CLI mode, <em>most</em> of the time (not always), the script will hang at the end of execution for about 5 seconds and then output this:</p>

<blockquote>
  <p><code>Error in my_thread_global_end(): 1 threads didn't exit</code></p>
</blockquote>

<p>It doesn't seem to actually have any effect on the script itself.</p>

<p>Some web searches turned up blogs which suggest replacing the php_mysql.dll with a different version, however this has not solved the issue for me, and I suspect the info from those blogs is now out of date.</p>

<p>My setup:</p>

<ul>
<li>PHP Version 5.2.4</li>
<li>Apache/2.2.4 (Win32)</li>
<li>Windows Vista Home Premium SP1</li>
</ul>

Did you take a look at
this resource
? You may want to double check that you got a specific libmysql.dll (5.2.1) that is unaffected by this, and also to double check that you don't have any stray mysql libraries lying around that PHP could be picking up instead. Or, switch from FastCGI if that's an option for you.
For interests sake, the bug appears to be best detailed
here
. The general idea of the problem (from the mysql bug link) appears to be:
```
```
Whenever a new thread is created libmysql is told about that by Windows. It then     
increases a thread counter and initializes some data. When libmysql is being unloaded
it checks whether all threads have finished, if not it tries to tell them "close now"
and gives them 5 seconds for that. In general this works in a nice way.
```
```