Check the state of the stack at the end

If the stack is empty, then the chain is valid, otherwise not valid.