I cheerfully plead guilty to locking at least half a dozen pupils in cupboards for being a damned nuisance on various occasions during my time as a teacher. It was a quick and effective way of dealing with them and enabled me to get on with teaching those who wished to learn something.
Spare a thought for this chap, then
Once I even forgot about one of them, left the room at the end of the lesson and had to hastily return fifteen minutes later to let him out of my stock cupboard. (To the horror of the teacher who was teaching French in my classroom)