Fix Database and ScriptingManager singletons

Their destructors will now be called when we shutdown the server.