[JS] Save db tree on window unload.