only close span-tag if it had been opened