Improve tab closing