SAN FRANCISCO (KRON) – An off-duty pilot who allegedly tried to bring down a commercial flight from Washington to California on Sunday engaged in casual conversation prior to “losing it,” according to court documents.

The documents, released Tuesday, recounted the moments leading up to the incident.

Horizon Airlines Flight 2059 was forced to make an emergency landing in Portland, Oregon, on Sunday evening after a “credible threat to an authorized occupant” on board.

Authorities said an off-duty pilot, identified as 44-year-old Joseph D. Emerson, was sitting in the plane’s jump seat and allegedly “attempted to disrupt the operation of the engines” by pulling the fire handles in the cockpit.

It’s common for off-duty pilots to ride in the jump seat on their way to commute to or from work, or to major air travel hubs.

Before the incident, though, the on-duty pilots reported “zero indication of anything wrong” with Emerson, a commercial pilot with Alaska Airlines. (Alaska Airlines owns Horizon Airlines, a regional carrier.) Earlier in the flight, he engaged them in “casual conversation” about the weather and his career with Alaska Airlines.

But court documents indicate that Emerson later in the flight abruptly threw his headset across the cockpit and declared “I’m not OK,” one of the pilots told authorities. He then grabbed the fire handles, which shut off fuel to the engine, according to court documents.

The two pilots in the cockpit with Emerson were reportedly able to subdue him and declare an inflight emergency. Emerson initially resisted their efforts, physically engaging with one pilot for 25 to 30 seconds before settling down, documents state. He was then asked to leave the cockpit.

Documents also cite the testimony of flight attendants who received a message that Emerson was “losing it” and needed to get out of the cockpit.

One of the pilots estimated that a total of 90 seconds elapsed between Emerson saying he was not OK and leaving the cockpit.

Emerson was seen “peacefully walking to the back of the aircraft” after leaving the cockpit. Documents then state that he told a flight attendant he’d just been “kicked out of the flight deck.” He then said, “You need to cuff me right now or it’s going to be bad.”

Flight attendants sat him in a seat at the back of the aircraft and placed cuffs on his wrists. During the plane’s emergency descent into Portland, Emerson turned toward an emergency exit door and tried to grab the handle, the documents say.

Flight attendants were able to stop him from opening the door and engaged him in conversation to prevent him from trying to grab the door handle again, documents state. Another flight attendant said Emerson made statements that included, “I messed everything up” and that “he tried to kill everybody.”

A flight attendant saw Emerson take his phone out and begin texting. He was also heard saying he had put 84 peoples’ lives at risk, his own included.

Once the plane landed in Portland, Emerson was arrested.

During an interview with officers, documents state that Emerson believed he was having a “nervous breakdown” and that he had not slept in 40 hours. He also admitted to feeling dehydrated and tired. During his interview with police, Emerson admitted to trying to pull the emergency shutoff handles.

“I didn’t feel OK,” he reportedly said. “It seemed like the pilots weren’t paying attention to what was going on. They didn’t … it didn’t seem right.”

He also told officers he pulled the handles because he “thought he was dreaming” and wanted to wake up. He denied taking any medications but said he became depressed six months ago.

It was not immediately clear from the court document if Emerson was high on mushrooms when he was on the plane, but an FBI agent wrote in the probable cause affidavit that the pilot spoke with police about the use of psychedelic mushrooms and “said it was his first-time taking mushrooms.”

When asked whether Emerson took psychedelic mushrooms right before the flight, Kevin Sonoff, the spokesperson for the U.S. Attorney’s Office for the District of Oregon, said that was still under investigation.

At the Port of Portland police department, Emerson said he would waive his right to an attorney. “I’m admitting to what I did,” he said according to documents. “I’m not fighting any charges you want to bring against me, guys.”

A criminal complaint from the U.S. Attorney’s Office District of Oregon states Emerson has been charged in federal court with one count of interfering with flight crew members and attendants.

Emerson was to remain in state custody pending an initial appearance in U.S. District Court in Portland, the U.S. attorney’s office said in a news release.

The Associated Press contributed to this report.