DIY Do not extend the region background
By default, the background of the region face extends from the end of the line to the edge of the window. To limit it to the end of the line, we need to override the face’s ‘:extend’ attribute. Adding this to the Emacs configuration file will suffice:
emacs-lisp
;; Do not extend `region' background past the end of the line.
(custom-set-faces
'(region ((t :extend nil))))