Action for minimizing or closing a window

Would be great to have an action for minimizing or closing a named window of a named application (simulating pressing the red or the yellow button), even if the window is not in front.