Malaysian police on Thursday shot in the head a man who took 30 pre-school children and four teachers hostage at a kindergarten, ending a dramatic seven-hour standoff. Authorities said all the children and their teachers were rescued unharmed after a sharpshooter ended the crisis in southern Malaysia with a single shot. "We have ended the hostage taking. The children and teachers are safe. The hostage taker armed with a hammer and machete has been taken to a local hospital," a local police official said on condition of anonymity. Witnesses said the children were calm and showed no fear as they emerged from the building, singing songs led by their teachers and walking into the waiting arms of their cheering parents who hugged them tightly. Johor deputy police chief Jalaluddin Abdul Rahman told reporters that the hostage-taker was alive but in a critical condition. The children and teachers have been taken to hospital for medical checks. Police took action after numerous attempts to secure a surrender -- from police negotiators, a local psychiatrist, and desperate family members -- all failed. Heavily armed police had surrounded the two-storey bungalow that houses the kindergarten, in Muar town in southern Johor state, and tried to coax the hostage-taker to free the children. Police said they had also brought in a dozen members of the elite Special Action Unit from the capital Kuala Lumpur, who are trained for anti-terror operations and are skilled sharp-shooters. Muar was also the scene in March last year of another kindergarten siege when a man armed with a hammer barged into a school and bludgeoned three six-year-olds who were left with head injuries. Some 20 children at the school were eating breakfast when that attack happened. The 45-year-old kindergarten operator was also injured in the incident. The New Straits Times newspaper said that the same man was responsible for both the March incident and the current hostage situation but police were not immediately able to confirm the report. The Star newspaper said the man had told police negotiators to give him a gun or he would kill the children. Frustrated over the prolonged crisis, family members began shouting over the fence of the compound, appealing for the man to surrender. The Star English-language daily said that two police trucks had rolled into the kindergarten compound and that two ambulances were on standby during the crisis.