How to close render 'View Render' after the render by bpy.ops.render.render()?
The new window has context after op call.

EDIT: Looked into this and remembered it did as expected using a timer.  Hence added a timer call in handler to delay the window closing.  Have run this numerous times with delay 10 seconds without any crashes.  Try with smaller delays.

Worth mentioning the behaviour of render operator depends on User Settings &gt; Interface &gt; Editors &gt;  Temporary Windows  Render in new window being set. 

If it is, the context is switched from old to new window when the operator is invoked. 

Another way to get a new window would be to 

windows_before = set(context.window_manager.windows[:])
.. operator ...

windows_after = set(context.window_manager.windows[:])


and get the new window via

new_window = (windows_after - windows_before).pop() # if there is a new window


Here in a test script, the render window is cancelled (closed with close operator) 10 seconds after, using a timer,  the render complete handler is fired..  

This will go astray, prob a core dump because of removed reference to window. if the user manually closes the window.  Passing instead some info about the window eg it has one image editor  its index in window manager collection would be a way to alleviate this risk.  Also might pay to look at context.mode after render call, to see if it reveals anything useful.

Python console test, get its index, test is this the render window?

&gt;&gt;&gt; C.window_manager.windows[:].index(C.window)
0
&gt;&gt;&gt; len(C.window.screen.areas) == 1
True
&gt;&gt;&gt; C.window.screen.areas[0].type == 'IMAGE_EDITOR'
False


Using the window close operator, i believe only requires having a window for context.

import bpy
from time import sleep

context = bpy.context
w = context.window
print(context.window)
bpy.ops.render.render('INVOKE_DEFAULT')
print(context.window, w == context.window)
c = context.copy()


def shut_window():
    bpy.ops.wm.window_close(c)
    return None

def render_complete(scene):
    bpy.app.timers.register(shut_window, first_interval=10)
    #shut_window()
    bpy.app.handlers.render_complete.remove(render_complete)

bpy.app.handlers.render_complete.append(render_complete)