Fixes unload, remove element only when still in dom