This happened to my cousin, Mary, who is only a couple of months younger than I am.
When we were both 9 years old her grandfather (from the other side of the family) got very sick and was taken into hospital. They had always been very close as she was his eldest grandchild and, since he moved in with her and her parents after his wife's death a couple of years previously, they'd gotten into a routine where he'd come into her bedroom say goodnight every night.
After he'd been in the hospital for about a week Mary and I spent the day together at our mutual grandparents' home but it was arranged I would spend the night at her house. When we finally got there it was late so we went to bed straight away, she to her room, me to a guest bedroom. As soon as she'd climbed into bed her grandfather came into the room, sat on the edge of the bed and told her he loved her and would always be with her. She went to sleep happy knowing he was alright. When she woke up the next morning the first thing she did was come and find me to tell me that her grandfather was alright and then she went to his room to find him. He wasn't there so she went to her mother in the kitchen and asked where he was, she told Mary that just as we'd gone to bed last night she'd gotten a call from the hospital saying that her grandfather had passed away suddenly but she hadn't wanted to tell her for fear of upsetting her too much.
Nobody believes me when I tell this story, they say it was all wishful thinking on my cousin's part or even outright lying but I have heard of similar stories from other people including other members of my family and believe that, sometimes, when a person is dying they wish to say goodbye to their loved ones and by some mighty effort of will some of them accomplish it.