Different parts of the world began and ceased building defensive walls at different time periods. Almost always, however, they stopped due to several things:
The idea of defensive walls didn't fade into the wind per se, but societies moved toward isolated fortification - Forts, Camps, specfic (usuaully militaristic) stretegic locations that could withstand bombardment. This was much more cost effective than trying to keep a wall around the entire city when they were expanding at too fast a rate to keep building around. In cities such as Cologne, and parts of the Beijing, the wall became an obstacle and served no further purpose. Or after witnessing their uselessness against mortar and artillery weaponry, cities ceased rebuilding walls (Copenhagen comes to mind).
Bombards had been used in many a siege. When the Turks sieged Constantinople in 1453, one weighed 19 tons, took 200 men and 60 oxen to emplace, and could only fire a few times a day. Sieges became progressively more and more advanced until, by my best estimates, the 1800s when civilizations ceased creating walls and moved to more tactical/ economically sensical defenses such as the star fort, first seen in late 15th century Italy. Menno van Coehoorn and Vauban are famous engineers of such forts. These were then developed further toward polygonal forts in the 19th century with further artillery developments and explosive shells. One of the earliest examples of a polygonal fort would be Fort Tigne in Malta, built sometime in the 1790s.
A "famous" example of city walls failing would be in 1807, when Copenhagen came under siege by the British in an attempt to seize the Dano-Norwegian fleet. Copenhagen was surrounded by walls - I can't find exact build dates, but I do have this map of Copenhagen in 1675, and one in 1800.
A small British force landed south of Copenhagen commanded by General Wellesley and defeated a force of Danish Militia/ Regulars, allowing them to establish an offensive position, including mortar pits. The city was surrounded, and to make a long story short, artillery from both the sea and ground positions overpowered the city in just days. An estimated 5,000 munitions were launched the first night (September 2nd), and some 7,000 on September 5th. This is notable because the Crown Prince was preparing for an invasion, to include an attempted British seige of the walls into the city. That never happened - the British didn't need to. The walls were worthless, and the Prince sued for peace after 200 civilian deaths and some 600-1,000 injuries depending on your sources. The British walked away with 24 battle ships, 17 frigates, 11 brigs, and 3 gunships.
There are dozens of city walls that stand to this day, including places in Great Britain, Western Europe, the Baltics, and East Asia. Most records I can obtain (I'm getting a list of resource together, as this has been a subject that fascinates me greatly) show the greatest walls being built at or before the 14th century. It appears the 15th century might be the cut off from a very general point of view, but as stated at the beginning of my comment, it really comes down to the advancement of siege/ artillery weaponry and the development of technologically superior defenses, starting in the late 15th century.