Added a wraper to ensure the connection is closed after a call as the connection was being left open.