This happens when I use my YouTube app sometimes (it's not the most stable of Nintendo's 3DS apps) but this particular error has never happened while I was playing a game. It has inexplicably gone black before while I was playing Sun and it didn't do anything afterwards, but nothing like the sequence you described. Like you said, everything was fine after that blackout error.
Which 3DS system are you using? Are you using a 3DS XL or the standard version? Perhaps it differs between the two.