It could be the shifter is loose, worn bushings.
Is there alot of side to side play when shifter is in gear?
Have a look here at the replacement of the bushings: TRS Magazine - Shifter Bushing Replacement
If the shifter is not pushing the Dog gear all the way into the gear then it can pop out when pressure is removed, like slowing down, this can also be caused by worn shift fork or Dog gear, these would be specific to one gear set, like 1-2 or 3-4 or 5-reverse.
This would require removal of transmission to repair.
The popping out of gear does cause excessive wear on parts, so should be avoided, hold it in gear until repairs can be done.