Separated some into function

Made the stop recording test into a function because it's in two places now.
It's a bit strange now because it's playing back whenever you move the window,
but that is just a temporary thing.