Is it possible to have the window opened by PlugInstall close automatically if the command ends without an error?
So I don't have to go manually write :wq
This isn't a solution to what you are asking but I believe you can just hit 'q' to close the pluginstall window.
There is currently no API to check if there was errors during installation. I know It's not ideal but you can examine the content of the buffer, i.e. the progress bar on the second line will contain x characters if there was errors. So I can imagine something like this:
command! PlugInstallAutoClose PlugInstall | if getline(2) !~ 'x' | q | endif
Note that this won't work as expected on Neovim as the command is asynchronous and returns immediately.
Most helpful comment
This isn't a solution to what you are asking but I believe you can just hit 'q' to close the pluginstall window.