Hi, yes, Avast Mobile Security runs in the background and protects your device in real time, unless it is killed by another app or feature (there are various power boosters and battery savers that kill apps running in the background to improve performance or battery life).
To prevent this we use the Permanent notification (you can check it in Settings > Notifications & alerts > Realtime protection > Permanent notification). You can also check the
www.dontkillmyapp.com site, that describes how various manufacturers work with the power enhancing features and how to adjust the settings to protect the apps you actually want to keep running.