It just does what you told it to do: display the time of window creation. Everything else would be some kind of miracle or at least a bug.

If you want it do display the time of the last window creation before this time (and I think that's what you intend to do), you would need some kind of persistant storage for your time tag, as closing the window also shuts down your app.