Matlab: Detect Peaks and Signal Jump
I think the easiest option is to detect the massive sudden increase/decrease.
Try calculating the difference between samples. If this difference is too big (positive or negative), we substract this difference on all future measured samples.

Create a variable for this offset. start with an offset of 0, when de absolute value of the difference between samples is too big, add this (non absolute) difference to the offset, then all next samples are $x_{new}=x-offset$.