Look at the diagram below. See figure 30 ? That's the ejector. During normal operation the magazine follower pushes up on the ejector causing it to lock the slide back. It sounds like you have either a magazine follower or ejector that is bent or worn or possibly a weak magazine spring. Does it fail with all your magazines or just one ? You might just have a bad magazine.
Field strip your pistol and make sure that the ejector moves up and down freely. It's spring loaded and should normally rest against the frame. Now watch your ejector while slowly inserting an unloaded magazine. What happens ? The follower should push it up about 0.70" or 2mm..