Edit a plist file in LaunchAgents to automatically close the application window on launch

I have an app that launches in background every time I reboot the computer, but for some reason the main icon remains on the dock until I click it and close manually the main window (or using the shortcut "command+W"). Then, the app remains in the background and its icon is only visible in the menu bar as I want.

I would like to edit the file in the LaunchAgents folder so that its main window closes as soon as the application starts at system startup.

Is there a way to do this? Is there any code that I can add or edit in the plist file to achieve this? Maybe emulating the keyboard combination to close the window?

This is the current application code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.companyname.appname</string>
	<key>LimitLoadToSessionType</key>
	<string>Aqua</string>
	<key>Program</key>
	<string>/Applications/appname.app/Contents/MacOS/appname</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Applications/appname.app/Contents/MacOS/appname</string>
		<string>--background</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

Thank you very much.

Edit a plist file in LaunchAgents to automatically close the application window on launch
 
 
Q