Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:34:14

And when We decreed for Solomon death, nothing indicated to the jinn his death except a creature of the earth eating his staff. But when he fell, it became clear to the jinn that if they had known the unseen, they would not have remained in humiliating punishment.  

And when We decreed for him, for Solomon, death, in other words, ˹when˺ he died — he remained supported against his staff an entire year, while the jinn continued to toil in hard labour as was customary, unaware of his death, until ˹finally˺ when a termite ate through his staff, he fell to the ground ˹and was seen to be˺ dead — nothing indicated to them that he had died except a termite (al-ard is the verbal noun from uridat al-khashaba, passive verbal form, in other words, ‘it ˹the piece of wood˺ was eaten away by a termite ˹al-arada˺’) that gnawed away at his staff (read minsa’atahu or minsātahu, replacing the hamza with an alif, meaning a ‘staff’, so called because ˹when describing it one would say˺ yunsa’u bihā, to mean it is used to repel or drive away ˹creatures˺’). And when he fell down, dead, the jinn realised, it became apparent to them, that (an, is softened, in other words, annahum) had they known the Unseen — comprising what was hidden from them in the way of Solomon being dead — they would not have continued in the humiliating chastisement, ˹in˺ that hard labour of theirs, ˹in which they continued˺ as they supposed him to be alive, which is in contrast to what they would have supposed had they known the Unseen and the fact that he had been there an entire year, judging by how much of the staff the termite had eaten through after his death; in other words, ˹they would not have continued in the humiliating chastisement˺ for a single day or even a single night ˹longer˺.
القرآن:٣٤:١٤

فَلَمَّا قَضَيْنَا عَلَيْهِ الْمَوْتَ مَا دَلَّهُمْ عَلَىٰ مَوْتِهِ إِلَّا دَابَّةُ الْأَرْضِ تَأْكُلُ مِنْسَأَتَهُ ۖ فَلَمَّا خَرَّ تَبَيَّنَتِ الْجِنُّ أَنْ لَوْ كَانُوا يَعْلَمُونَ الْغَيْبَ مَا لَبِثُوا فِي الْعَذَابِ الْمُهِينِ  

{فلما قضينا عليه} على سليمان {الموت} أي مات ومكث قائما على عصاه حولا ميتا والجن تعمل تلك الأعمال الشاقة على عادتها لا تشعر بموته حتى أكلت الأرضة عصاه فخرّ ميتا {ما دلهم على موته إلا دابة الأرض} مصدر أرضت الخشبة بالبناء للمفعول أكلتها الأرضه {تأكل منسأته} بالهمز وتركه بألف عصاه لأنها ينسأ يطرد ويزجر بها {فلما خرَّ} ميتا {تبينت الجن} انكشف لهم {أن} مخففة أي أنهم {لو كانوا يعلمون الغيب} ومنه ما غاب عنهم من موت سليمان {ما لبثوا في العذاب المهين} العمل الشاق لهم لظنهم حياته خلاف ظنهم علم الغيب وعلم كونه سنة بحساب ما أكلته الأرضة من العصا بعد موته يوما وليلة مثلا.