Fix an issue that causes exception when destroying an widget is not initialized or already destroyed.