The attached patch makes simpleTest close and forget the connection before returning.
It also fixes another problem with the test: The test starts four threads that use a shared connection to perform queries. However, it returns just after starting the tests, and doesn't wait to see if the threads succeeded. The patch makes it wait until the threads have completed before returning. (This part of the patch was needed to prevent the new cleanup code to close and null out the connection before the threads were done with it.)
The test is still a bit strange, though. For example, it ignores exceptions in the threads. Only wrong results cause a test failure.