add try catch on window unload widget destroy