I also had this problem and I couldn't find a proper solution. It annoyed me so much that I wrote a utility which automatically restore window placements when the display connections are back to normal. Try it out!
You can find the source and a compiled version here: https://github.com/gurrhack/RestoreWindows