Approach heavy bag and grip the top of the bag. Jump as high as you can and close the guard. Gently let yourself down until your hands touch the ground, then sit up. To make more difficult, wear a weight-vest.
Note: You MUST have bare skin touching the bag. Do this with pants on and you will slid right down, especially if you use a slick leather bag. Even with bare skin, if you are not sweaty you may find it difficult to perform more than couple of reps at a time without sliding.
I very rarely close my guard. I feel like there is little you can do with a closed guard except stall, so I immediately open mine after securing the position. I like to keep one leg in a high position across the back of the neck and the other towards the lower back. In this position, I can move swiftly into the rubber guard (and all the subsequent positions) or move that bottom foot to the hip to initiate a sweep or submission. A lot of beginners tend to lock down the guard, which makes sense, but I find they do so in order to stall or rest, which is not necessarily a bad thing. There are many resources to explore for using the closed guard, but as a personal preference, I like to keep mine open.
Although a closed guard is employed to gain control from the open, an open guard does not necessarily mean your opponent can easily escape. The key is to keep your opponent controlled within the guard while you begin to set up submissions and sweeps. Thus, it is important to have strong inner thigh and core muscles to build a strong open guard.
Although I am definitely crossing my feet during this sit-up, it takes an inordinate amount of leg strength to keep your body suspended in the air on the heavy bag. Closing the guard during this exercise is required; I doubt anyone could stay up without doing so. However, after working this drill into your repertoire for several weeks, you will find your thighs and abs noticeably stronger and your open guard more difficult to escape.