You'll want to make sure battery optimizations are disabled for them, so Android will be less likely to close the app for only being in the background. Sometimes allowing the app to keep a persistent notification going can help as well. A lot of the specific details can vary by phone and android OS version, so web search will be your friend on this.
I'll warn you though, with some phones, you can do everything right and it may still auto-close them on occasion.