By John Seewer | Associated Press

A seventh-grader who shot and killed himself inside an Ohio middle school restroom last week was planning to shoot others at the school before changing his mind at the last second, a police chief said Thursday.

The boy, 13-year-old Keith Simons, came out of the bathroom holding a semi-automatic rifle just before classes began and then abruptly went back inside and shot himself in the head, said Jackson Township Police Chief Mark Brink.

Start your day with the news you need from the Bay Area and beyond.

Sign up for our new Morning Report weekday newsletter.

Police don’t know why Simons didn’t carry out the attack and probably never will, the police chief said. “We should thank God every day, whatever made him change his mind,” Brink said.

Investigators found messages on his cellphone that showed the teen had been planning an attack for at least a week at Jackson Middle School, near Massillon. He also showed admiration for the two students who carried out the Columbine High School shooting in Colorado nearly 19 years ago.

“I’d hurt and destroy something bigger but my schools an easy target,” Simons wrote in one message found on his phone.

“I want to leave a lasting impression on the world,” he said in another message written days before he took the.22-caliber gun to school on Feb. 20. “I’m going to die doing it.”

CLICK HERE if you are having trouble viewing the photos or video on a mobile device

Check out the other stories on Uber Health and the Northern California storm.

The messages indicating he was planning a school shooting began a week earlier, the same day that 17 people died in the school shooting in Parkland, Florida, Brink said.

Police said Simons rode a bus to school and concealed the gun under his clothes. He also had a backpack with extra ammunition, bottle rockets and batteries.

Simons went into the restroom as soon as he arrived at school, Brink said.

At about the same time, surveillance video showed he came out of the restroom and there were four students nearby, but for some reason he turned around, Brink said. Another boy in who was the restroom saw the gun and ran to tell school officials, he said.

Simons died a day later and the Summit County Medical Examiner’s Office ruled the death a suicide.

The chief said it doesn’t appear anyone else knew about the boy’s plan.