A criminal prosecution of two police officers accused of tasering and restraining a prisoner with a mental illness comes to an end after a judge finds they could not be guaranteed a fair trial.