close db connection whenever necessary