fix bugs for tabs closing