I have tried so many ways but they always seem to fail for whatever reason. For example I had a husband lock his cheating wife in her bedroom with enough food preparing things to create flies but that was when I found that locking the doors to her room doesn't stop service NPCs from going in and cleaning it. I just removed the doors but even then she lived for so long I finally just let her out for her preserverence. Those "non-locking for service NPCS doors" also allows the cowplant to eat nannies while the parents are at work (if you want to guarantee a visit from the social worker). Since the plant seemed to randomly eat people walking by I think those locks may not work on those outgoing sims that invite themselves in too so I just don't use it. I kept just losing people unless I remembered to completely take the gate off.
You may wish to try Authorized Personnel Only. Unlike funny Maxian locks, Authorized Personnel Only does not grant exception merely for sims that have set themselves in the "leaving" state, so sims are not allowed to enter restricted areas in their quest to attempt to leave.
Also, it seems that the robots "do chores" doesn't allow them to die without turning freewill off. I had one take a bubble bath so social, fun and power were red but all she did was run outside trying to recharge (she couldn't because of outside music which I thought was odd but oh well). Finally I locked her up with all 3 still in the red and she just continuously tried to recharge while the social bunny laughed at her.
Robots cannot die of exposure. Nothing which relies on low motives to kill tends to work on robots, since they don't have any critical killable motives.