When the player leaves the server, you cannot save or fetch their wanted level as it’s too late - they’ve disconnected.
The solution to your scenario is to store the player’s wanted level server-side by triggering a server event the moment they receive the wanted level. If the player’s wanted level increases/decreases then call your server to update itself again so your server is aware of the current wanted level for your player all the time. Then when the player disconnects, you can simply use the disconnected player’s ID as a reference to fetch their wanted level from the server to store on the database.