In the late game, if I'm on a 3-4 bases and building tier 2-3 army (Terran Air), I end up with a ton of extra minerals. There are usually no more available expansions and I only have 1 or 2 barracks because I raced up the tech tree. Where should I be spending my minerals?
This indicates that you should probably be picking up additional gas geysers sooner in the game, essentially as soon as you feel that you can safely do so.
As a Terran, you can also make additional Orbital Commands using the minerals and then sacrifice SCV's to your opponent. This slows down that income and also makes room for additional troops, since Mules don't use up any supply. Against Zerg on maps with choke points you can also create Planetary Fortresses as a way to gain map control.
If you feel they'll be useful, reactored Blue Flame Hellions are a cheap way to reinforce an army, assuming you've gone Mech into Starport play and have the armory upgrades already.
When you have more minerals then gas, just invest in infrastructure like Barracks. It does not matter if you did not go MMM in the first place, but every Terran army can be backed up by a steady Marine stream.
The idea is the following: You will get 200/200 eventually, then there will be a big fight where both armies will get decimated. Reinforcing with "big" units takes a lot of time and there will be a period where both players have small armies. Battlecruisers for example take 90 seconds and are not that fast. You cannot have a lot of Factories / Starports as they cost a gas. So building a "meaty" Mech or Air army takes really long.
During this time MMM is really strong. The smaller the armies the better Marines are. Plus they are very mobile.
Depending on your enemy you might want to add other structures like Turrets, Bunkers or Command Centers. Sometimes even more Supply depots on the other end of the map might be a good investment, so you can actually profit from a base race. While your opponent struggles with supply and production facilities you have a perfectly fine base in every corner of the map.
The golden rule of SC2 macro is to expand aggressively and spend aggressively: get income, and spend it as quickly as you get it. Anything less is inefficient: any income you're missing, or income that's sitting in the bank, is income that could be used to improve your economy or military.
To this end, some casters/tutors recommend that you build 2-3 production buildings for each expansion as Terran. That's 2-3 more barracks, factories, or starports, for each expansion. As income rate increases, especially with mules and/or gold expansions, you need to continually invest in your infrastructure (production buildings, reactors, upgrade buildings, etc) to be able to spend it as fast as you earn it. So, you may benefit from just slamming down additional barracks or even starports. 1000 minerals in the bank does nothing for you, whereas 20 more marines has at least the potential to help you.
For any build, there are nuances about which production buildings to build when, which upgrades to research when, and so on. But I would recommend just trying to build more production buildings to spend it in various ways. If you have too much money, find (any) way to spend it. When I first did more of this, I was surprised by how large an army I was able to field in a small amount of time.