A judge has stopped the prosecution of a man accused of breaking into a woman's home and raping her, after hearing he had died.

Michael Unwin, 49, was due to face a retrial on the matter after the jury failed to reach a verdict on the allegation in March.

But after learning that Unwin had died in an apparent suicide a judge at Swindon Crown Court closed the case, ruling that the indictment was of no legal affect.

Charles Thomas, prosecuting, told the court on Friday: "He sadly committed suicide on May 11.

"It has been investigated. A copy of the death certificate has been obtained which I can hand to you."

Judge Douglas Field said being satisfied the defendant had died he ordered the indictment be endorsed accordingly and the file be closed.

The jury was discharged after they failed to reach verdicts following a five-day trial on charges of rape, attempted rape and threats to kill.

Unwin was said to have broken into the ground-floor flat, where the woman was living with her toddler, before carrying out the attack.

The woman said during her ordeal he told her he would kill her if she did not comply with his wishes.

Unwin, of Oak Road, Chippenham, insisted the woman had wanted him to come round and visit her in the early hours so they could have sex. He had denied all the charges.

The woman, who was 41 at the time of the alleged incident, sobbed as she recalled the alleged incident at her Chippenham flat on Thursday, December 6, 2012 at the hearing. 

She said Unwin, who she knew, was wearing dark clothing and latex gloves when he attacked her.