When I open Vim from a terminal, copy some text to the system clipboard, and exit Vim, the system clipboard gets cleared.
How to keep the copied text in the clipboard?
Synthesizing answers from superuser, just add the following to your .vimrc
autocmd VimLeave * call system("xsel -ib", getreg('+'))