A common fault with the Mazda CX-5 and the Mazda 6 is the vehicle will not turn off from accessory position. That is to say the engine will turn off with the stop start button but the accessories wont power down and all the lights remain on the dash.
The part at fault is the neutral switch which is part of the shifter assembly.
This switch will require replacing to rectify the fault but as a short term solution you can normally get he switch to turn off if you play with the shifter by moving it from right to left whilst its in the Park position.
Below is a short video demonstrating how to get the switch to turn off.