I've always felt like this about it. The Bible says it's not His will that any perish, therefore if you pray for their salvation, you are praying in His will. If you pray His will, your prayers will be answered.
You know how when you dream, it seems to last for hours or even days, but it actually only lasts seconds? I think that in the seconds before death, there is ample time for salvation. That is why I have no problem praying for salvation for those who are already dead. God exists outside time, He can answer prayers years before you ever pray them.