Detach previous UI with the same window.name (#10338, #12255)

Change-Id: I15234985f1591d6af383c6e014679762619d5000