I want to hide app icon from the Dock that are running but doesn't have an active window. I googled it, but the answers I found were all app specific.
I am looking for a generalized solution.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
In general, majority of macOS apps are programmed to display it's icon in the Dock when it's running (exceptions are apps which display an icon only in the Menu bar when running).
If an app icon is not added permanently to the Dock, it's icon remains visible as long as it's running. The icon is removed from the Dock upon quitting the app by selecting App Name → Quit App Name from the app menu, or by invoking the keyboard shortcut Command + Q with the app in focus.
So, the only way to remove an app icon from the Dock is by quitting it.
Some apps are programmed to automatically quit when it's last visible window is closed either by clicking on the close button
at the top right, or when the close window keyboard shortcut Command + W is invoked.
Thus, it's up to the developer of the app to choose which of the two behavior to implement, and can not be changed by user.