free linked list before exit