I think your confusion is with the terminology. The largest element in the sequence 1, 2, 3, 4 is the number 4. The second-largest element is 3, the third-largest is 2, and the fourth-largest is 1. Since the algorithm returns 1, it works correctly.
However, 4 is the kth-smallest element in the sequence. If you want to find the kth-smallest element, you can just swap the min-heap with a max-heap and make the appropriate tweaks to the algorithm.
Hope this helps!