MouseX and MouseY return the mouse in layout coordinates taking in to account the display zoom and angle. So if you change the display angle you change the values MouseX and MouseY return which in turn changes the display angle... and you get a strange feedback loop that probably involves the screen spinning really fast.
To fix this add a new layer called "Coordinates" or something. Never scale or rotate this layer - it's just for getting coordinates. MouseX("Coordinates") and MouseY("Coordinates") will then return the unzoomed, unscaled mouse coordinates, and you can use these to set the display angle for other layers (not the whole display, otherwise it'll still affect the Coordinates layer). Hope that helps.
By the way, it often helps to have "Unbounded scrolling" enabled for rotating screens.