Don't render empty tabs. Close open tabs when clicked.

From #4728.