Because Heraclitus never said anything straight forward and appeared to despise his fellow man, it is fitting that the end of his life should be so undignified.
Καὶ τέλος μισανθρωπήσας καὶ ἐκπατήσας ἐν τοῖς ὄρεσι διητᾶτο, πόας σιτούμενος καὶ βοτάνας. καὶ μέντοι καὶ διὰ τοῦτο περιτραπεὶς εἰς ὕδερον κατῆλθεν εἰς ἄστυ καὶ τῶν ἰατρῶν αἰνιγματωδῶς ἐπυνθάνετο εἰ δύναιντ᾽ ἐξ ἐπομβρίας αὐχμὸν ποιῆσαι: τῶν δὲ μὴ συνιέντων, αὑτὸν εἰς βουστάσιον κατορύξας τῇ τῶν βολίτων ἀλέᾳ ἤλπισεν ἐξατμισθήσεσθαι. οὐδὲν δ᾽ ἀνύων οὐδ᾽ οὕτως, ἐτελεύτα βιοὺς ἔτη ἑξήκοντα.
And finally becoming a misanthrope he withdrew from society and lived in the mountains eating herbs and wild plants. Because of this he got dropsy, so he returned to the city and asked the doctors in a riddling way if they could make a drought after heavy rain. When they failed to understand him, he dug himself into a cowshed hoping that the dropsy would be evaporated by the heat of the dung. He failed in this and ended his life aged sixty.
Or another version of this
Ἕρμιππος δέ φησι λέγειν αὐτὸν τοῖς ἰατροῖς εἴ τις δύναται ἔντερα κεινώσας τὸ ὑγρὸν ἐξερᾶσαι: ἀπειπόντων δέ, θεῖναι αὑτὸν εἰς τὸν ἥλιον καὶ κελεύειν τοὺς παῖδας βολίτοις καταπλάττειν: οὕτω δὴ κατατεινόμενον δευτεραῖον τελευτῆσαι καὶ θαφθῆναι ἐν τῇ ἀγορᾷ. Νεάνθης δ᾽ ὁ Κυζικηνός φησι μὴ δυνηθέντ᾽ αὐτὸν ἀποσπάσαι τὰ βόλιτα μεῖναι καὶ διὰ τὴν μεταβολὴν ἀγνοηθέντα κυνόβρωτον γενέσθαι.
Hermippos says that Heraclitus asked the doctors if anyone could draw off the water of the dropsy by emptying his intestines. When they said they couldn’t he put himself into the sun and told his servants to plaster him with cow dung. Stretched out like this, he died the next day and was buried in the agora. Neanthes of Cyzicus says that he stayed put because he couldn’t tear off the dung and on account of this change in appearance he wasn’t recognized and so became dogfood.
Diogenes Laertius 9.1
The fact is that these stories are not true but are made up of various elements of his philosophy. Fire (or the soul) is transformed into water and then earth – then back again. Getting dropsy – a watery disease – showed that his soul was becoming less pure so he tried to rectify this by heating it with dung.