Locksmith is another settlement Fallout 4 mod that we recommend.
Locksmith allows you to lockup your containers and doors in your various settlements. This will prevent NPCs from going where they shouldn't and it will prevent them from stealing items in your containers, Items like ammo and food.
Locking up a door/container is extremely easy. Walk up to the thing you want to lock and press the correct button. Done.