I heard someone say that when one passes away we have to close their eyes.
Where in halacha does it say this? Why do we do this?
The reason why we close the eyes of someone who passed away is to show the idea of techiyas hameisim just like when someone sleeps he closes his eyes and when he awakes he opens them so to the dead will reopen their eyes with techiyas hamaisim (nishmas chaim maimer beis perek chof hey)
Another reason is brought in lechem haponim siman shin lamed tes We cinder the eyes of the dead... because as long as it can see this world it cannot see the next world (olam haboah)
The source in shulchan aruch is yoreh deiah siman shin nun beis seif daled
Mourning in Halacha, p 50 says
Then the eyes of the deceased are gently closed and he is covered with a white cloth.
He gives the sources as:
Gesher HaChaim 3 (this may be the link)
Ma'avor Yabok (Sifsei Rannenus 9) “They cover the face of the deceased so that the accusers should not increase his suffering by gazing upon his face and forehead where a person's sins are engraved. Moreover it is forbidden to look at the face of the deceased, lest one lose respect for him. In addition to these reasons, there is the statement in Horayos 13b that looking at the face of thedead causes one to forget one's learning.”
Not sure its anything spooky. See the last mishna in chapter 23 of maseches shabbos, page 151b in shas, it mentions closing the eyes of a dead person, which we can't do on shabbos. The gemara there discusses that closing a person's eyes prematurely is murder, and if someone WANTS to close a dead man's eyes there is a proper procedure so as not to accidentally kill him while he is still a goseis.
The mipharshei mishnayos quote an Aruch who simply says 'the closing of the eyes is so they won't be open, as is written and Yosef will place his hands on your eyes, parshas vayigash ch 46 vs 4.'
If you look in the Ibn Ezra on that passuk he simply says 'he will place his hands on your eyes, when you die, thats the practice of the living with the dead'. In any event, the practice is apparently very old.