A variant of this is this piece, which was the way I prevented the top of this cabinet from sliding forwards:
Another example is this a snap-lock. Similar to a common plastic snap-lock used for things like bags and rucksack straps, this involves a piece of plywood shaped with a hook and whose ‘arm’ is cut thin enough to be able to bend as the unit is inserted into a slot. The hook end needs to be sloped so that the arm is gently allowed to bend as you move it further into the slot. Once it gets far enough, the arm will snap back into its preferred position and the lock will secure it.