Yes, the data is deleted when you logout. You will lose all data that has not been synchronized.
As far as I know, there is no way to avoid data being deleted.
The workaround I implemented when I faced this issue, is that I show the user a large pop-up when they log-out, which tells them they will lose their data if they continue. I provide them with three buttons in the pop-up: synchronize, log-out, and cancel.