Fixed bug when closing tab