How to automatically pause a playing media on bluetooth disconnect
As per apple's policy , when you cross the bluetooth limit of your headset your system  will be automatically switch the audio output into the internal speakers.Mostly in platforms are like that.

But there are many third party apps like , Breakaway  is a utility that will pause/resume iTunes for you whenever you unplug and/or plug in your headphones. You can now walk away from your computer for a moment without missing a beat of your favorite song, or disturbing anyone with your speakers coming on.