To prevent this from happening, you can employ a sealing substance like Henkel's Loctite red threadlocker. This nifty goo can be drizzled into a screw's threading, sealing it in place with ...
While high-temperature threadlocker derivatives exist, typical Loctite-branded threadlocker (and similar products) would not appear to be able to stand the heat of a typical soldering iron.