The prevailing theory is suicide by self-cannibalism; The Silmarillion tells us:
Of the fate of Ungoliant no tale tells. Yet some have said that she ended long ago, when in her uttermost famine she devoured herself at last.
The Silmarillion III Quenta Silmarillion Chapter 9: "Of the Flight of the Noldor
Interestingly, at one point Tolkien intended that Eärendil (Eärendel at that stage of the narrative) would kill her; in a 1926 outline for the Silmarillion, he wrote (emphasis mine):
Earendel weds Elwing. The call of the sea is born also in him. He builds Wingelot and wishes to sail in search of his father. Ylmir bids him to sail to Valinor.' Here follow the marvellous adventures of Wingelot in the seas and isles, and of how Earendel slew Ungoliant in the South.
History of Middle-earth III The Shaping of Middle-earth Chapter 2: "The Earliest Silmarillion"
I'm not entirely clear when this notion was abandoned, but it was sometime before the writing of Return of the King; in an early draft, Frodo and Sam encounter her (not Shelob) in Kirith Ungol:
'Got you!' hissed Gollum in [Sam's] ear. 'At last my precious one, we've got him yes, the nasty hobbit. We takes this one. She'll get the other. O yes. Ungoliant will get him.
History of Middle-earth VIII The War of the Ring Part 2: "The Ring Goes East" Chapter VIII: "Kirith Ungol"
When Tolkien came back to writing The Silmarillion, we see that Ungoliant's fate is undetermined:
But when she had healed her hurts and spawned [in Nan Dungorthin] a foul brood she passed away out of the Northlands, and returned into the South of the world, where she abides yet for all that the Eldar have heard.
History of Middle-earth X Morgoth's Ring Part 2: "The Annals of Aman"