The Selection.collapseToEnd() method collapses the selection to the end of the last range in the selection.
Selection.collapseToEnd()
MDN Reference