Yes, it can refer to the closest noun too, as in the following sentence.
All I can say is that I finally picked up Gima's cookbook last spring at the age of 41, when I found it at the bottom of a box, which I was finally unpacking because I was finally settling into the house where I hope and pray to finally stay put.
It is the box being unpacked, not the bottom of the box.
It depends on the context, though. In the following sentence, which is not referring to crime but to "he has never been convicted of a crime."
He has never been convicted of a crime, which suggests that he doesn't pose a threat to society, legal experts said.
It's not thea crime that suggests he doesn't pose a threat to society, but the fact he has never been convicted of a crime.