I have a game where you have “game sessions” which take place in one level, and it’s obviously a good idea to make sure that any buffered RPCs are being cleaned up before and/or after any particular session. I do that on “game over”, which in fact just means “game session over”, and when loading the level (which is starting the session).
Also, I need to keep track on the server of the logged in NetworkPlayers and do some cleanup when “everyone’s gone” (just like after a good party ). I do this by simply keeping a List networkPlayers where I add and remove the players when they’re being added or removed.
What you can also see in this code-snippet is that I have a singleton GameData which knows whether or not this is a “Standalone server”. But that, I can use different code paths where needed. I have a checkbox “IsStandaloneServer” in a game object component in my startup scene (probably would be best to have that in a “NetworkingStuff” game object, that handles all these things and is always available and accessible from everywhere via a “Unity-conform” singleton).