Loitering at or near a school is a misdemeanor that is punishable by up to six months in jail and a $1,000 court fine. If the defendant is a person who is required to register as a sex offender under California Penal Code Section 290 PC, the maximum fine amount on a first conviction for loitering at or around a school increases to $2,000. If the defendant is required to register as a sex offender and has a previous conviction under California Penal Code Section 653b PC, he or she must serve a minimum of 10 days in jail. And if the defendant is required to register as a sex offender and has two or more prior convictions for loitering in or around a school, that person must serve a minimum of 90 days in jail custody.
Police have a wide range of latitude to determine that a situation is an emergency and can do a number of things to prevent the emergency from getting worse. Things have changed significantly now that many police are required to wear recording devices- it's now clear that some police abuse their authority.
They also shan't use the word "shan't".
The last time I heard "shan't" spoken was by a leprechaun some twenty-odd St. Patrick's Days ago.
And there's no "right" way to act in those situations. Charles Kinsey got shot, lying on the ground with his empty hands on the air, because the police were afraid when they responded to a complaint. The shooter kept his job, retired, and got 100 hours of community service and had to write a letter of apology.
That being said, there are lots of crimes which could start with loitering outside a school, even if the locality doesn't have a law specifically against loitering in front of schools (which many do), loitering with intent to commit a crime is against the law, and the police only need "probable cause" to arrest you. "Looked suspicious and refused to move on when asked" could very well be enough to establish probable cause.
"5. Loiters or remains in or about school grounds, a college or university building or grounds or a children's overnight camp as defined in section one thousand three hundred ninety-two of the public health law or a summer day camp as defined in section one thousand three hundred ninety-two of the public health law, or loiters, remains in or enters a school bus as defined in section one hundred forty-two of the vehicle and traffic law, not having any reason or relationship involving custody of or responsibility for a pupil or student, or any other specific, legitimate reason for being there, and not having written permission from anyone authorized to grant the same or loiters or remains in or about such children's overnight camp or summer day camp in violation of conspicuously posted rules or regulations governing entry and use thereof; or"