It is actually legal to keep students after the bell. There are no direct laws against keeping people in class after the bell rings. Also, your school's policy or regulations can specifically say different rules about the bell. However, teachers must be careful not to abuse their power to keep students after the bell.