I was able to reproduce only when my device had not yet connected to the Worklight server in any way (has not yet logged into the realm, initOnStartup=false, no adapter calls, etc)
It appears that if the client has not yet communicated with the Worklight server, it knows nothing about the realm and so it throws an error when trying to log out of the realm. Try either adding a check to see if the user has logged into the realm or making sure that the user has connected to the Worklight server before they are able to log out.
Even if they haven't yet logged into the realm, the device will know about the realm if it has connected to the server at least once.