OK, Just in case you guys didn't know, PHP closes all database connections opened by plain connects when the script finishes running.
HOWEVER, if the script / apache process running the script dies abnormally, then the connection can be left open, in a kind of zombie state. The database thinks there's a client on the other end, while the actual client on the other end went bye bye and the connection won't get reused.
If this is happening enough to cause you to run out of connections, then something on your apache / php server needs attention. A common cause for this kind of problem is when apache is compiled against one version of a library, and php against another version of the same lib. For instance, it was a common problem back when OpenLDAP sdk and and Netscape's LDAP sdk were fighting it out for superiority for a machine to get set up this way.
IF this is happening, your apache error / access logs should show some clues.
Now, if you're using pconnects (which I recommend you do NOT use, generally) then a close_connect will have no effect.
Note that closing a connection as soon as your done with may help a bit in this situation, as it might be that whatever is causing your php scripts to crash isn't hitting them before they close the connect, but the real problem is that something is making your apache / php child processes die.
But wait, there's more!
You can adjust your tcp keep alive parameters to "harvest" those dead connections more quickly. The default tcp keep alive settings are to wait 2 hours to check, then tries to ping it (technically, it's not really a ping, but it's the tcp keep alive equivalent...) 9 times every 75 seconds (in most linux and unix environments.)
If you're running linux, you can see them as root by typing in :
sysctl -a|grep keep
which will show you something like:
net.ipv4.tcp_keepalive_intvl = 75
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_time = 600
The 600 is the time to wait (so on this machine, it's been reduced from the default of 7200 i.e. 2 hours, to 10 minutes.)
The 75 is the interval between rechecks once the connection is thought to be possibly dead, and the 9 is the retries.
To set them on a linux box, edit the /etc/sysctl.conf file and put those lines above we got from the sysctl -a|grep boogie in there and edit them. Then, to put them into force, enter 'sysctl -p' as root.
So, in your environment, you can drop the keepalive_time to 300 or so, and drop the probes to 3 or 4, and the intvl to 20 or 30. With settings of 300/3/20 for those, you'd have to wait 5 minutes, plus 3*20 seconds, or 6 minutes for dead connections to be reported by the tcp stack back to the database, at which point the database should kill off the connection and it should be available for use again.
whew. That was longer than I wanted. Hope it helps.