Properly closes dbconnection