Core: Fixed premature destruction of windows appref