I'm using a ConnectionPool (more specifically a MongoClient) to connect to a server and after some use I wish to terminate the connection.

I've see that removing the ConnectionPool variable does not actually destroy the object and the connection stays open.

I don't want to end up manually freeing memory since I believe it will cause several problems. So how can I terminate the connection?

Thanks for any help.