Fix bug removing the last open tab

* Now check to see if index > 0 and the active tab is not null