This was my experience.
If you are locked outside the fence, don’t panic. There is a surveillance camera up on a lamp post next to the resting hut near the gate. Police can see you after a while if they are monitoring the CCTV. They will come when they see you. In this case, you have to have your permits ready for inspection. I did not have to wait long last time before they came.
If you have mobile phone with you, you can call the number on the notice board at the gate to have the police to come to open the gate for you. Unfortunately, you cannot see the notice board from the outside of the fence. Nor you can check the number through PCCW directory hotline. So remember to note the gate closing time and bring along the phone number with you when you go out to mudflats.
BTW, I suggest that HKBWS posts the phone number somewhere easy to locate on this website so that people needs it can find it handy here.