If you're hearing a noise from the fusebox I would check to see if there is a loose connection to the fuse for the door locks, or if there are any signs that the wiring has overheated. If the connection is loose this means the joint resistance is high and the volt-drop means the voltage at the door actuator may not be high enough to lock it. It may take less current to unlock the doors which is why it seems ok when opening. That's just speculation on my part. It would be odd if all 4 locks were faulty, which is why it is more likely to be a common fault like a bad connection at the fuse, weak battery, or if there's a relay which actually switches the power to the locks, it could be that relay which is faulty or the connections where it plugs in.