You could take advantage of the state machine within Alexa, I would suggest to have different state, besides the default regular one, to have the StopIntent there. In this case you could switch to this state when you are playing the sound and only then your particular Stop behavior will work, there you can return to the regular state which wouldn't have a default behavior on your skill so it will run the default one from the Alexa itself closing your skill.
In this code you can have a basic idea on how this could work, though for sure there is stuff missing, but the important things are the this.handler.state
which controls in what state is the session at the moment, and Alexa.CreateStateHandler(state, intents)
which gets as parameter the name of a particular state and the particular behavior for the intents on that state.
const Alexa = require('alexa-sdk');
const defaultHandlers = {
PlayIntent: function() {
// move to state 'PLAY'
this.handler.state = 'PLAY'
// Code to play
}
}
const playingHanders = Alexa.CreateStateHandler('PLAY', {
PlayIntent: function() {
// Code to play
},
'AMAZON.StopIntent': function() {
//output to available screen
makeTemplate.call(this, 'stop');
// move to default state
this.handler.state = ''
this.response.speak('Ok. I sent a practice tip to your Alexa app.').audioPlayerStop();
this.emit(':responseReady');
this.response.shouldEndSession(true);
}
})
module.exports.skill = (event, context, callback) => {
const alexa = Alexa.handler(event, context, callback);
alexa.appId = APP_ID
alexa.registerHandlers(defaultHandlers, playingHanders)
alexa.execute();
}
There are many tutorials on this on internet so you can find better ideas on how to take advantage of this.