As I realized that my smartphone was getting short of battery capacity a bit too fast, I made this simple task that force closes active apps, including those running in the background that you don't see.
The task uses Autoinput to simulate closure by the end user. The list of apps to close is expected to be stored in an input file (apptoclose.txt in the description I provide) as list of relevant package names. For example, com.amazon.mShop.android.shopping if you want to kill the Amazon app.
IMPORTANT: You don't want to kill apps that
1 - must stay in the background in order to function, e.g. Whatsapp
2 - Are part of the Android o.s.
Please note that I momentarily switched both the Android and Tasker language settings from my mother tongue to English in order to share the task description and although I double checked it all, there might be still some typos left.
I hope this task will be of use for some of you as it is for me.