There is no specific event, for the main script, when the script is reloaded. It wouldn't be reliable anyway, because people usually reload because the script has crashed.
In a plugin, you can use OnPluginSaveState function to save things before the plugin saves its state (which it does when it is being reloaded), or OnPluginClose, which is called when the plugin is being closed.
I would tend to keep stuff in plugins, once debugged, because of the automatic saving.
If you don't want to do that, you could save periodically (say, every minute or five), so that if you have to reload, you haven't lost everything.
Another thing you could do is make your own alias for reloading the script file, which first calls a function (to save stuff), and then does:
world.DoCommand "ReloadScriptFile"
Then make an accelerator to overload Shift+Ctrl+R, so that if you use that to reload the script file, it still calls your alias.
http://www.gammon.com.au/scripts/doc.php?function=Accelerator