The problem can be fixed in the 0 to Count-1 loop. When you close the first tab (0), then the original tab(1) becomes tab(0). So keep removing tab(0) to remove all tabs. Otherwise you will only remove every other tab. This doesn't fix the ForEach enumerator loop. This must work with the index values...