This actually happens quite a bit, so I decided to capture an instance in a save
for you to potentially look into.
If you grab anything out of the shelves there while the cook is facing you, he will eventually finish his routine and come after you, even though there is a wall there.
I forgot to mention that it's not enough to teleport out, some NPC across town will come up to you and mention you stole something. Probably unrelated but still a bug.