Fix crash when quickly attaching/detaching tabs