There is a small switch that the lower door hinge operates when the doors are fully open. It is located at the end of the bottom rail and is covered by a piece of pivoted plastic that can break and prevent the door operating the "off" switch.
Looking up from underneath partly open door. Check the lightly spring loaded lever on the bottom "hinge" as this can sometimes seize on its pivots. If it doesn't swing out freely to operate the plastic lever as the door becomes fully open, the door will close again. If necessary free off the lever with penetrating oil and operate it until free again but watch out for your fingers (safer to do when the door is not fully open).
Picture taken with door partly open, looking down between body and door, looking back. This shows the position of the curved plastic flap over the switch. This pivots to operate the limit switch every time the door is opened.
The plastic flap is part #6 on the drawing - both sides the same part - Peugeot part 9137F1 "Headlamp Cover" (must be something lost in the translation)
Flap in position over microswitch - to fit, slide into the two clips SIDEWAYS or the limit stop (next picture) will get in the way.
This is how the flap should look - three "axles"; the upper two of which slide sideways into the two clips (next picture).
This is the (very small) microswitch itself - Item 5 on the drawing Peugeot 6559C6 left; 6559P9 right
Chances are that if it is clicking it won't need replacing - to me it looks a bit awkward and mucky to get at!
Martin Smith discovered that the microswitch will come out after removing all the torx screws securing the rail and cable clips to the car. After that there is enough room to unclip the switch.
The cable ends in a green plug, just inside the car and below where the door cables pass through. The pre-terminated pins are held in place with a yellow clip.
When the door becomes fully open and the limit switch kicks in, the backlash in the cable assembly allows the door to move forward down the slope slightly. Then the limit switch opens and the door closes again.
Carefully bend the end of the sprung-loaded lever on the hinge, where it presses on the plastic cover over the microswitch. Be careful with the fingers