fix segfault in event loop due to terms being removed from linked list.