Closing db connection after last item.