Fix closing tabs with invalid URLs. Fixes #163.