Plus! saves you messages quite quickly after they are send though. It used to be only after a certain amount of time (or even only when the convo was closed - dunno exactly anymore), but iirc this was already changed in Pus!4.
something....
As for an existing script: No, AFAIK there is no script to do exactly what you ask for.
But there is
ReadThis for example:
http://www.msgplus.net/Downloads/Download-Details/DocumentID/7880/
This will show you a toast if you close a chat window too quickly. Dunno if that may be of interest. I doubt it though, but just in case....
And there is
SessionSaver from fatfreechicken:
http://shoutbox.menthix.net/showthread.php?tid=79194
This one re-opens chat windows after a crash. But it does not restore messages which were send right before the crash though. At least not by itself. However, if you also enable "
Show my last conversation in new conversation windows" in Messenger, it usually will show you the last recieved messages (but only if Messenger itself was able to save them of course).
-----
Note: the above links might not work properly. The servers are being updated so it might be that you can't access this link or see the script in question.