How to close window but keep app running

I would like to implement an app like this. The app would run continuously in the background and try to receive messages from the socket, when a message arrives, a xilem window would pop up in the middle of the screen displaying the content of the message, and the user would view the message and close the window, and do the same the next time a message arrives.
My needs are the same as the issue,Someone gave the advice that use winit set window visible and the example were mentioned, but it’s too complicated for me. Is there an easy way to get winit handle? Or is there any other way to accomplish what I need :wink:

I modified the example/events, but the second time it loops it creates the window with an error