How to keep Spotify from closing?

Sign out of Spotify. Uninstall Spotify. Clear the cache partition and reboot. Reinstall Spotify and sign in.
If it still occurs, if you do have your battery optimizations off, then shoot them an email about your bug. Good luck