is it legal to keep students after the bell as a punishment?
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.