getWidgets().closeOpenInterface();
imo any script is a good place to start. questing scripts are fine to start with if the person understands how to use configs.
as for your theory on the bot actions, below are what some bot devs think jagex looks at, not what you're talking about. jagex could probably care less if you click the x to close or not. they're more worried about where you're clicking, how fast you're clicking/reacting, etc. see examples below
botlike:
humanlike: