Property is unexpectedly changed when closing a window

Ideally there should not be behavioural differences like this but sometimes they are unavoidable