Fix message trimming that resulted in trailing escape backslashes

It was only trimming the final backslash, leaving the other, which ended up escaping the final quote being appended on the next line.