Solar flares are often, but not always, associated with coronal mass ejections. Why do coronal mass ejections accompany some solar flares but not others?

Some solar flares are associated with explosive coronal mass ejections, which can disturb Earth’s protective magnetosphere. The resulting geomagnetic storms generate dazzling auroras, but they can also interrupt radio communications and damage power grids. [SOHO (ESA & NASA)]
To Erupt or Not to Erupt
When a solar flare is blissfully unaccompanied by a violent eruption of plasma from the Sun’s surface, we call it a confined flare — the solar atmosphere remains bound to the surface rather than lashing out into interplanetary space. An eruptive flare, on the other hand, occurs when a coronal mass ejection is released along with the solar flare, exploding material out into the Sun’s surroundings.
It’s not yet clear why some solar flares are confined while others are eruptive. One possibility has to do with the arrangement of the Sun’s complex magnetic field. Twisted and tangled field lines can rearrange themselves through a process called magnetic reconnection, which accelerates charged particles and heats the plasma.
If, after reconnection, the magnetic field is either in a low-energy configuration or it’s sufficiently constricted by stronger magnetic fields farther from the Sun’s surface, no eruption will occur and the flare is confined. But how can we figure out what actually happens during confined flares?
Out on a Limb

The July 24, 2016, solar flare as seen in three extreme ultraviolet channels by Solar Dynamics Observatory. Panels a, b, and c show the progression of the flare from the beginning to the peak to the end. Click to enlarge. [Ning et al. 2018]
To sidestep this issue, Hao Ning (Shandong University, China) and collaborators investigated the magnetic configuration of a flare extending from the edge of the Sun’s disk — the solar limb — where the bright arcs of plasma are clearly silhouetted against the dark background of the sky.
Ning and collaborators combined observations of a confined flare from the space-based observatories Solar Dynamics Observatory (SDO) and Ramaty High Energy Solar Spectroscopic Imager (RHESSI), as well as the Nobeyama Radioheliograph on the ground.
Time Evolution of a Solar Flare
Light curves extracted from the flaring region showed not one peak but two, which is thought to signal the presence of magnetic reconnection. Why two peaks? Magnetic reconnection in the corona accelerates charged particles, which then interact with the relatively dense chromospheric plasma. This interaction produces high-energy X-rays (the first peak) and heats the plasma, causing it to emit thermally at lower-energy X-ray wavelengths after a short delay (the second peak).

Soft X-ray light curves from RHESSI and hard X-ray light curves from the Geostationary Operational Environmental Satellite (GOES). The two peaks are labeled Stage A and B. The double-peaked behavior is evident at almost all energies. Click to enlarge. [Ning et al. 2018]
Because of the unusually high energy, Ning and collaborators conclude that the plasma must be heated not only indirectly, by collisions with particles accelerated by reconnection, but also directly, by reconnection itself. This observation of a super-hot plasma component in the second stage of a confined flare is the first of its kind — and surely further observations will reveal new details of how confined flares evolve, continuing to build our picture of what determines confinement vs. eruption!
Citation
Hao Ning et al 2018 ApJ 854 178. doi:10.3847/1538-4357/aaaa69