Now more careful about using completed events to detect tabs, avoids closing tabs that shouldn't be closed.