What Happens To Joe Kennedy III or Ed Markey When One of Them Loses Tuesday?

Either U.S. Representative Joseph P. Kennedy III or U.S. Senator Edward Markey will lose the Democratic Senate primary in Massachusetts this upcoming Tuesday.
Since that's the case, then what? What ends up happening to the losing candidate? Will he be done with politics, or will there be another role for them to serve?