If a door wont close properly and remain closed - most likely first
Possibly one of the multi-contacts at the front edge of the doors and the A-post needs a clean. These need to make as the door closes so the rear actuator knows to pull the back of the door in. If the latch misses for any reason the door will open again. I clean mine about once a year.
Use fine sandpaper - the sort you might use for the last rub-down before house painting. You need to take off any surface dullness and end up with a shiny smooth finish. Don't be tempted to use a file as you could short across the contacts and blow a fuse; sandpaper is quite safe.
Do pay particular attention to any black spots, they usually appear on the fixed A-post contacts. The reason for using sandpaper and not emery or wet-and-dry paper is because the hard bits of emery might embed into the metal and might create more problems. Afterwards just wipe off with a clean cloth; no need (in fact best not to) spray anything on them.
Next, check that the outside door handle has returned fully forward under the action of the internal spring. Pull the handle right back; release so it springs forward without help - and then check it won't move any further forward. If the doors are usually operated from the key-fob then over a period of time the outside mechanical handle can become stiff because of a build up of oxide on the hinge mechanism. To fix this, spray the pivots with WD40 penetrating oil very occasionally.
Also double-check there is nothing dropped or jammed in the door aperture that could possibly stop it fully pulling in. Also try "helping" the door to pull in by pressing the back of the door inwards as it closes.
Unusual - but on a very hot day, a door distorted slightly, causing the TOP locating spigot to HIT the socket instead of sliding in - the electronics sensed something was in the way and the door opened again. I chalked the spigots to see what was happening and could see where the chalk was left on and around the sockets. Ten seconds with the socket set to adjust the top spigot and no more "won't close" door problems.
Unusual - door failing to close fully and opened again was due to a very rusty spigot which had flaked and expanded so didn't fit easily into the hole in the A-pillar. Caused by water running down into the rubbery shock absorber on the spigot.
Perhaps obvious, the catch at the back of the door (that latches onto the rear actuator) can be accidentally flipped over so the door lock catch cannot get hold of the hoop (see pictures below). This HAS happened to someone after servicing - he hadn't realised he'd flipped it over. Clear simply by operating the external door handle; you should hear the catch click back.
A few have found the in-door actuator sticks in the fully retracted position and the internal spring isn't strong enough to push it back out again; this prevents the door lock working. This means that, when the door closes, the lock cannot grab the B Post Actuator so registers a "fail to close" and opens again.
As the cars age, bear in mind that it is possible the connectors on the backs of the multi-contacts at the front of the door and/or A-post are deteriorating both are only held on by a single bolt so it may be worth while taking them off and cleaning the plugs and sockets behind.
You might spray a little grease into the door lock at the back though generally they don't cause problems. Do NOT be tempted to lubricate the door rollers or the guides.
A few have found that the B-Post Actuator , after moving outwards to release the door, then pulls back in. This means that, when the door closes, the lock cannot grab the B-Post Actuator so registers a "fail to close" and opens again. This MAY need a new B-post actuator, although one or two have simply reseated the plug in the socket and all came good.
one final thought - after you have tried everything else above. A few have found that if you pull the cable attached to the in-door actuator too hard - the lock at the rear of the door can occasionally jam in the unlocked position. A solution to this is to slacken the lock mounting screws (not too far, just enough so you can move the lock assembly a little). You may be lucky and hear a click as the lock unjams (is that a word?) - and retighten.
Door lock - rear of left door shown
If the lock catch doesn't get hold of the hoop then the door won't pull in and the electronics will signal a failure.
Door lock - rear of right door shown
If the lock catch doesn't get hold of the hoop then the door won't pull in and the electronics will signal a failure.