Mr. Katsav resigned shortly before his term ended in 2007 at the end of his presidential term , under a plea bargain that would have required him to admit to lesser charges of sexual misconduct .