close pdo connection after request ends

When a request finishes and the PDO connection is not closed in
userland and it is persistent, we need to explictly close it to
prevent excessive amount of connections (and eventually causing
MySQL to reject them).

This can obviously be solved in userland by closing the connection in a
register_shutdown_function, but we need to be consistent with PHP.