26
There are a few things going on that could cause this. First, it sounds like you may be resting the rifle too close to the hinge point. Try resting it a bit further forward. Second, as mentioned, you may not be closing it all the way. You may also need to make sure the barrel latch mech has been thoroughly cleaned. Sometimes this means taking it apart. Metal shavings have been found in there that hamper the latch mech and keep it from functioning properly.
It doesn't happen freehand because you have upward pressure on the forearm when holding the rifle and it keeps it closed.
You have to close these with a firm motion. Don't be too gentle, you won't hurt it.