That happened to me a couple of times recently when I was having all kinds of shifting problems. When I replaced my clutch cable yesterday I found the old one would barely move. If your cable is old like mine maybe it's hanging up like like my old one.
Usually it pops out because the gears aren't completely engaged.
Not pulling up with a firm shift can cause this, I call it lazy shift.
This can happen with heal/toe shifters also. Check the shifter is moving completely.
If the clutch is adjusted properly and otherwise working right I'd look for a bent shift fork. This is not very common.
I was having that problem with a BMW once until I learned I wasn't shifting right....when I am shifting up I now load the shifter and then do a quick squeeze of the clutch lever....going down the same.....load the shift letter than a snap squeeze of the clutch...works smooth as butter and I always have a positive engagement of gears...
Brian