Per the original question, I would slowly wean your horse off the magnesium and see if you notice any changes. If you see changes you don’t like, then put him back on it and keep him on both. If not, then just do the ulcer supplement.
However, IMO, ulcers should be addressed at the basic feed level before adding supplements. I do not like the idea of feeding items that irritate ulcers, then supplementing with things that are supposed to soothe the stomach. Remove the irritation in the first place.
It is best to remove all grain from the diet of a horse prone to ulcers, however for horses that are difficult to keep weight on, a grain with NO corn and NO molasses is best. These both contribute to inflammation of the ulcers. I use Tribute Kalm N EZ for my hard-to-keep and nervous/spooky mare. After her second round of Omeprazole, I did remove grain completely from her diet, and replaced it with Alfalfa pellets (10 lbs a day). This maintained her weight, but she is not a fan of alfalfa pellets, so I switched to Kalm N EZ. She is not a fan of grain in general, but eats this well enough.
During the switch and for a few months just to maintain, I gave her an ulcer supplement and Aloe juice. However, I have not had to use either in over a year with the Tribute grain, and she has not had a recurrence.
If Tribute is not available in your area:
Nutrena does not have any grains completely free of corn/molasses.
Purina does have a few options.
I believe Buckeye has a few options.
Seminole has one option.
I am not sure about Triple Crown.