Use Enum.take/2 with a negative value:
iex(1)> list = [1, 2, 4, 5, 6, 7, 8, 9, 9, 88, 88]
iex(2)> Enum.take(list, -4) |> IO.inspect(charlists: :as_lists)
[9, 9, 88, 88]
take(enumerable, count)
[…]
countmust be an integer. If a negativecountis given, the lastcountvalues will be taken. […]