Close subprocess by timeout even if it opens new window

Hey everyone!
I have a function that periodically pings IP. For this I use subprocess to call os ping.
In some extreame cases ping cannot be started (not enough memory). When this happens it opens new window with this error. While the window is opened the function waits for it to complete.

So, my question is how to close it by timeout even if this window is opened.

async def ping():
        proc = subprocess.Popen(['ping', ''], stdout=subprocess.PIPE) 
        result = proc.communicate(timeout=10)[0]  # I assume it freezes here
        if proc.returncode == 0:
            await process_result(result)  # some processing of the result
    except Exception as e:

OS: Windows 10
Python: 3.9

A command terminal plus ping does not need much memory.
Sounds like you have a serious problem if you get that not-enough-memory pop up.

Are you running on a Windows 10 with small memory? These days 8GiB or more is typical. How much memory does your PC have?

The task manager would be where I start to check for what is using up your memory.

I suggest you find out what is using all your memory rather then try to figure out now to close that dialog.