Remove whitespace and terminal characters when truncating