gh-155860: Reject a detached window in panel.replace() (GH-155861)