Judge resigns after improper IMs with wife