I tested only with tracks from Apple Music subscription also with songs from my library (old CD rips from iTunes), and it seems to work.)
I recommend to let the script run in a terminal window, but you can create an actual application by wrapping the script with Automator (I found the instructions here).
I think it is not possible to stop the application from GUI. It is possible from Terminal though: if you called your app ListenBrainzScrobbler, for example, run: