In scansion, a vowel is long by position if there are two or more consonants between it and the next vowel. Can a vowel be long by position if it ends a line and there is no next vowel? E.g. is the "E" in "REX" long if it is the last syllable in a line? I am particularly concerned with the case for dactylic hexameter if it makes a difference for the answer to the question.
In scansion, a vowel is long by position if there are more than two consonants between it and the next vowel.
This is the usual way of putting it, but it's inacccurate/misleading in a couple of ways.
First, it's not really the vowel that is long by position; it's the syllable that is long, or in a different terminology, "heavy". (Linguists these days speak of "light" and "heavy" syllables, to avoid possible confusion with "long" and "short" vowels.)
Second and relatedly, the reason that a vowel followed by two or more consonants is "long by position" is really that in such a case, the syllable ends with a consonant, and is therefore heavy: e.g. a word like centum gets syllabified cen-tum, and any syllable that ends with a consonant (like cen) is heavy, i.e. can fill a "long" verse position.
What this all leads to is that it doesn't matter whether the word is at the end of a line or not: a word like rex will always form a heavy syllable, so will always count as metrically long.
(That said, since you're asking about dactylic hexameter: in that meter, any syllable, light or heavy, can stand at the end of a line, so in that context, everything I said above actually doesn't matter. Even a syllable with a short vowel and no final consonant can stand at the end of a hexameter line.)