swiping music player does not kill the process? Swiping programs from the process-list should kill/shut them down, right?

I listened to music and then swiped the music player away but the music was still playing.

How come?

Does swiping not kill processes? if so, how can i close them correctly?
Taking Google's Music app as an example (I would wager most others are implemented similarly), there are two distinct parts that constitute the app:


The foreground processes and tasks that the user interacts with
The background service that actually handles music playback


Point 2 can be verified in this Android Developer's blog post wherein it is stated:


  Music playback runs in a service to allow it to continue operating after the user leaves the music application.


This distinction ends up being important when you remove an app from the recent tasks list. As covered in my answer to another question, the following is what happens when you swipe an app out of the list, as stated by Android engineer Dianne Hackborn:


  Actually, removing an entry in recent tasks will kill any background
  processes that exist for the process. It won't directly causes
  services to stop, however there is an API for them to find out the
  task was removed to decide if they want this to mean they should stop.
  This is so that removing say the recent task of an e-mail app won't
  cause it to stop checking for e-mail.


In this case, that means that the foreground tasks of the Music app are being stopped, but the background service (evidently) chooses to continue running. This is a product of the way the app is implemented, so you simply won't be able to stop music playback by swiping the app out of the list. Instead, you can try the following from the recent apps list (also covered in the above linked answer):


  If you really want to completely stop an app, you can long press on recent tasks to go to app info, and hit force stop there.