HUNTERSVILLE, N.C. - A 16-year-old Huntersville, N.C., boy shot and killed himself after threatening two other teens with a handgun at his high school.

Huntersville Police Capt. Michael Kee said Josh Cook was apparently upset over an ex-girlfriend and first brandished the weapon on two other students during the lunch period on Wednesday at North Mecklenburg High, the Charlotte (N.C.) Observer reported Thursday.

Cook drove away in his pickup truck and the threatened students reported the incident to the resource officer at the school, which is north of Charlotte.

Police were called, and the school was ordered into lockdown.

An hour later, officers spotted Cook parked at a gas station, again brandishing the gun. As officers approached from behind, ordering him to drop, he shot himself once in the head, cable News 14 Carolina reported.