GARDEN GROVE (CBSLA) — A mentally ill man who barricaded himself in a police car and fired a rifle from inside has been taken into custody early Wednesday.

A four-hour standoff outside Morningside Recovery, a drug and alcohol treatment facility, ended when 33-year-old Steven Matthews surrendered at about 12:41 a.m. and was taken into custody. He was arrested on suspicion of discharging the rifle and booked at Orange County Jail.

READ MORE: Police: Marcus Kelley Of Hemet Discharged Bear Spray In Seal Beach Road Rage Incident

Matthews, who had been staying at Morningside Recovery, was reported to be acting psychotic, Garden Grove police Lt. Carl Whitney said. When officers arrived at about 9:25 p.m. Tuesday, they were asked to stand by as an Orange County Mental Health worker conducted an evaluation.

It was determined the man needed to go to another facility for further evaluation and officers had the man wait in a police car until an ambulance arrived. The man was not under arrest and was not handcuffed, Whitney said.

While inside the police SUV, he somehow climbed into the front of the vehicle and got a hold of a semiautomatic patrol rifle and fired a shot, which went through the windshield, and sent the officers running for cover.

READ MORE: UCLA Study Find That People Already Infected With COVID Only Need One Dose Of Vaccine

The officers did not return fire, and no one was injured. SWAT officers were called to the scene and the vehicle was blocked in until Matthews surrendered after four hours of negotiation.

Garden Grove police supervisors will investigate how the suspect was able to gain access to the patrol rifle, Whitney said.

“At this point, it is unknown if the locking mechanism for the rifle failed or if the suspect somehow was able to trigger the release of the weapon,” Whitney said.

MORE NEWS: 40 Cows Escape Meatpacking Plant In Pico Rivera; One Killed By Deputies After Charging Family

(© Copyright 2018 CBS Broadcasting Inc. All Rights Reserved. City News Service contributed to this report.)