If you were able to pull the stem up to that point, it will come all the way out with a bit more twisting and turning. Just some WD40 sprayed at the point where the stem comes out of the headset will help a lot. I assume you didn’t just loosen the stem bolt, but also gave it a whack? That knocks the wedge out of the bottom of the stem, making removal a far easier task!