I am using the Spotify app on Windows 10. Unfortunately, every time that i have Spotify playing music and close the type cover on my Surface Pro X or press the power button to turn off the scree, the app quits playing music. I know this is not related to the device as it is the behavior on multiple devices. I have tested this with other apps (Grove Music) and it will continue to play music when the power button is pressed or when the type cover is closed on the device.
I have submitted this issue in the Windows 10 feedback hub here
https://aka.ms/AA8rk0c
Hopefully, Spotify can reach out to Microsoft to see what needs to be done to the app to enable playback when the device goes into sleep mode.