I know that would be the obvious. You asked for the obvious. Another cure would be to not get busted masturbating...or to find a girlfriend who doesnt just give uP
take it to the bathroom or a secluded spot and jack it off. i'm pretty sure the only cure for blue balls is ejaculating.
You can either orgasim or wait for your erection to go down and then it should go away. I've never had it happen to me before though. Some guys get it but their balls don't turn blue, but they still feel the discomfort.