There's this new things called "service workers" that run in the background all of the time. They're only allowed to react to events that happen, such as push notifications, and they can't affect other processes on your phone.
If you have no idea what I just said, don't worry. It took me a few days to understand how these things really work. The documentation on them is sparse and often outdated.