You can terminate these pipes underground in a dry well, with a mix of sand and coarse stones, as some of the other answers have outlined, but I strongly urge against doing so, because doing so makes what is going on underground invisible without excavating the whole area. What this means is that, if at any point down the line, you get a blockage and/or backflow, you have to dig up a huge portion of your yard just to access the area to figure out what is going on, let alone to fix it.
The probability of having to redo this in the long-run is high. A lot of things can go wrong:
- Over time, sediment can clog the drainage, so a size / drainage that was adequate initially, might not be in the long-run.
- A change to the environment, such as a change that makes more water drain into the soil, or an increase in severe rainfall events, or a change to the roof that leads more water to run off into this pipe, can make it so that you will need more capacity later.
- You might not size the well or drainage basin large enough to begin with, and it might be okay for a while, but you won't realize that it's big enough until you have a severe rain event. If you don't do this sort of work professionally, the chance of you sizing it wrong is very high. And because the sizing needs to be chosen on the basis of rare events, you might not realize that it's too small until months or years later.
- Changes in the surrounding hydrology which lead to an increase in the height of the water table could decrease the drainage rate or cause backflow, even if the amount of water flowing into the pipe stays the same.
A better option is to simply dig a basin that is open to the air, and then do the same thing: put a layer of sand at the bottom and then rocks on top of that. In this case, troubleshooting is very easy, because you can see exactly what is going on at a glance. Fixing a problem is also much easier, as the space is accessible. If the basin is in an area where the stakes are low for overflow (such as if it just runs downhill away from your home and/or temporarily floods an area of lawn) you can even dig these sorts of basins incrementally, like dig it, and every time it overflows, just dig it wider and/or deeper to increase capacity.
Furthermore, you get the very large benefit of being able to plant a rain garden around the edge of the basin or even in the basin, in which you can grow wetland plants or other water-loving plants that you might not have enough water to grow normally. So having the basin exposed actually becomes an asset. For eaxmple my yard is too dry for swamp rose mallow (Hibiscus moscheutos), a really beautiful perennial which is native where I live, but I have been able to grow it in a rain garden supplied by the downspout from the front slope of our house's roof. I have seen all sorts of different ways of doing these rain gardens or basins, you can have plants around the edge and open stones in the middle, or you can have the entire basin planted like an artificial wetland. Both options can be attractive, and typically it's a lot less work to maintain than mowing a lawn, you can mow or cut the plants in them once a year and periodically weed, but if the plants are chosen well for them they won't need much weeding.
So this is how I'd approach it. Yes, you can put it all underground but the chance of you regretting it later and creating a ton of extra work for yourself if you have it all covered up is very high. Just keep it out in the open and your life will be much easier.