On October 6, 1970, while on holiday in Istanbul, Turkey, American college student Billy Hayes straps 2 kg of hashish blocks to his chest. While attempting to board a plane back to the United States with his girlfriend, Billy is arrested by Turkish police on high alert due to fear of terrorist attacks. He is strip-searched, photographed and questioned. After a while, a shadowy American (who is never named, but is nicknamed "Tex" by Billy due to his thick Texan accent) arrives, takes Billy to a police station and translates for Billy for one of the detectives. On questioning Billy tells them that he bought the hashish from a taxicab driver, and offers to help the police track him down in exchange for his release. Billy goes with the police to a nearby market and points out the cab driver, but when they go to arrest the cabbie, it becomes apparent that the police have no intention of keeping their end of the deal with Billy. He sees an opportunity and makes a run for it, only to get cornered and recaptured by the mysterious American.
During his first night in holding at a local jail, a freezing-cold Billy sneaks out of his cell and steals a blanket. Later that night he is rousted from his cell and brutally beaten by chief guard Hamidou for the blanket theft.
He wakes a few days later in Sağmalcılar Prison, surrounded by fellow Western prisoners Jimmy (an American — in for stealing two candlesticks from a mosque), Max (an English heroin addict) and Erich (a Swede) who help him to his feet. Jimmy tells Billy that the prison is a dangerous place for foreigners like themselves, and that no one can be trusted – not even the young children.
Billy meets with his father, a U.S representative and a Turkish lawyer to discuss what will happen to him. Billy is sent to trial for his case where the angry prosecutor makes a case against him for drug smuggling. The lead judge is sympathetic to Billy and gives him only a four-year sentence for drug possession. Billy and his father are horrified at the outcome but their Turkish lawyer insists that the term is a very good result.
Jimmy tries to encourage Billy to become part of an escape attempt through the prison's tunnels. Believing he is to be released soon Billy rebuffs Jimmy who goes on to attempt an escape himself being brutally beaten for this. In 1974, Billy's sentence is overturned by the Turkish High Court in Ankara after a prosecution appeal (the prosecutor originally wished to have him found guilty of smuggling and not the lesser charge of possession), and he is ordered to serve a 30-year-to-life term for his crime. Billy goes along with a prison-break Jimmy has masterminded. Billy, Jimmy, and Max try to escape through the catacombs below the prison, but their plans are revealed to the prison authorities by fellow-prisoner Rifki. His stay becomes harsh and brutal: terrifying scenes of physical and mental torture follow one another, culminating in Billy having a breakdown. He beats up and nearly kills Rifki. Following this breakdown, he is sent to the prison's ward for the insane where he wanders in a daze among the other disturbed and catatonic prisoners. He meets fellow prisoner Ahmet whilst participating in the regular inmate activity of walking in a circle around a pillar. Ahmet claims to be a philosopher from Oxford University and engages him in conversation to which Billy is unresponsive.
In 1975, Billy's girlfriend Susan comes to see him. Devastated at what has happened to Billy, she tells him that he has to escape or else he will die in there. She leaves him a scrapbook with money hidden inside as "a picture of your good friend Mr. Franklin from the bank," – hoping Billy can use it to help him escape. Her visit moves Billy strongly, and he regains his senses. He says goodbye to Max, telling him not to die promising to come back for him. He bribes Hamidou into taking him to the sanitarium, where there are no guards. Instead, Hamidou takes Billy past the sanitarium to another room – and prepares to rape him. Fighting back, Billy inadvertently kills Hamidou by pushing him onto a coat hook. He seizes the opportunity to escape by putting on a guard's uniform and walking out of the front door. In the epilogue, it is explained that – on the night of October 4, 1975 – he successfully crossed the border to Greece, and arrived home three weeks later.

Question: How did Billy finally escape the prison after his last showdown with Hamidou?
Answer: He put on the police uniform and left through the front door