The coal industry started its decline around 1910 when Fisher, the First Lord of the Admiralty, and Winston Churchill, decided that all new warships should be oil-fired. The rapid take up of the same measure by civilian vessels saw around a 30% decline in the production of Welsh coal over the next two decades.
The next nail in the coffin of the coal industry was the introduction of electrical distribution. This meant that many industries, in particular the textile industry, could replace their inefficient and costly coal-fired steam systems, with much more efficient electric motors. A centralized system of electricity production in coal-fired power stations is far more efficient, and reduced the demand for coal. The gradual replacement of gas lighting by electric lamps also reduced the demand for coal.
Then came the great smog of 1952 and the passing of the Clean Air Acts. The largely removed the market for domestic coal.
We then decided, some years after most other countries, to replace steam trains by diesels and electrics. Another market gone.
In the 1960s we found gas in the North Sea. The market for town gas, produced from coal, disappeared in a very short time.
If you have no markets for coal it is not surprising that pits close!! This particularly applies to British pits where the takes are so disorganized, the coal is not of a very good quality (all the best coal was taken by the Victorians and Edwardians), and (due to our high land and property prices) the costs of subsidence are so high.
The final nail has been the introduction over the last couple of decades of bigger, faster and cheaper shipping, which has led to the lowering of the world price of coal.
We have arrived at a situation where even our open-cast coal has difficulty competing in the market place (see the bankruptcy of Scottish Coal, for an example).
The great shame is that when it finally dawned on politicians that the decline was inevitable, a (say 25-year) plan to manage the disappearance of the coal industry wasn't put in place.