The sunshade can be opened and closed by hand.
The sunshade opens automatically when the moonroof is opened, but must be closed by hand.

CAUTION
Jam-safe Moonroof
Security SystemMazda 6 Owners Manual: To Operate the System
The High Beam Control System (HBC) operates to switch the headlights automatically
between high and low beams after the ignition is switched ON and the headlight switch
is in the AUTO and high beam position.
The High Beam Control System (HBC) determines that it is dark based on the brightness
...
Mazda 6 Owners Manual: Glass panel adjustment
1. Fully close the glass panel.
2. Measure the gap and height between the glass panel and body.
3. If not as specified, loosen the glass panel installation screws and
reposition the glass panel.
Clearance
a: -0.8-1.2 mm {-0.032-0.047 in}
b: 0 mm {0 in}
4. Tighten the installation scre ...