Fix error when closing last tab
Fixes #2, #5