Structural rearrangement accompanying the ultrafast electrocyclization reaction of a photochromic molecular switch