Clamp getLast to a valid range.

The return value should be a valid index into the items slice, or -1.