An off-duty New Jersey police officer fatally shot himself in the head after crashing his SUV into two parked vehicles — and as first responders were preparing to free him from the wreck, officials said.

The 39-year-old Roselle Park cop lost control of his SUV about noon Sunday on Broad Street in Matawan and struck the two vehicles before partially rolling over, Chris Swendeman, spokesman for the Monmouth County Prosecutor’s Office, told The Post.

“As first responders left the vehicle to get equipment to help with the extraction, the driver located a firearm and fatally shot himself,” Swendeman said in an email.

The 13-year veteran was identified as Edward Nortrup, a resident of Aberdeen, NJ.

Nortrup “removed a gun in his possession and fired one shot tragically taking his own life,” Roselle Park Police Chief Daniel McCaffery said in a statement, adding, “We are grieving as a department for the loss of our officer.”

He told The Post: “He was very well-received by all who encountered him.”

Nortrup served in the Detective Bureau and was a member of the Union County Emergency Response Team, according to a post on the department’s Facebook page.

There were 17 police suicides last year and 37 since 2016 in the Garden State, according to NJ.com.

The state Attorney General’s Office recently launched the New Jersey Resiliency Program for Law Enforcement, which will require every officer by the end of 2022 to attend a two-day training session on mental health.

The head of the New Jersey State Policemen’s Benevolent Association said a call about a cop’s suicide is the worst kind they can get.

“I always feel like this is preventable. It’s not like a line-of-duty of death. There’s always danger out there but these are the deaths that are hard because somehow we missed this guy and didn’t get him help,” Patrick Colligan told New Jersey 101.5.