If you really want to close all database handles (that your thread has access to), and you don't care how they were opened, then I'd do this.
set total_num_handles [expr {5 + 5 + 5}]
for {set i $total_num_handles} {$i >= 0} {incr i -1} {
catch { ns_db releasehandle nsdb$i }
}
Totally hackish, but it should meet the "no matter how many were opened and what their variable names were" criteria. :^) I'd suggest backporting the database API though.