There are no laws that make it illegal for a teacher to keep students after a bell. With that said, the law does protect students from unfair punishment. In that regard, a teacher can't issue punishments that prevent a child from being able to eat lunch or go to the bathroom.