Apologies for the late reply on this!
I found that your method worked but then your use of quadrants got me thinking about Euler rotation matrices. So I tried instead learning the diagonal components of the rotation matrix and then running an atan2 method of retrieving theta. This worked like a charm in removing the discontinuity at 0/360 degrees and accounts for the quadrants too.