WARNING: This page is about a different car, the 2020 Mazda CX-30. However, it is still accessible from the selected car via links, so may be relevant.
To prevent the wire shown in the illustration from coming off the rail, install while aligning the wire in the rail.