Question: is it legal to keep students in class after the bell rings?
Answer: To recap, it is not illegal for a teacher to hold their students after the bell. This is your teacher imposing the powers of in loco parentis and looking to punish bad behavior by keeping you in detention, a non-corporal punishment, thus making it legal.