On the maximum orders of elements of finite almost simple groups and primitive permutation groups