close connections using finally block