gets the last value that has been added and removes it from the history.
if called on an empty history.