I've never tried this myself, but heard mixed things about how risky it is.
On the down side, wort is incredibly sweet and tasty for all kinds of bugs, and once you're done mashing, it will cool down right through the warmish danger zone where germs can grow most quickly. So if anything nasty does get in there, it could grow like mad (no yeast to compete with, remember) and easily spoil your wort by the next morning.
But on the up side, as long as you mash out with an elevated temp, your wort will be at least mostly sterile, and as long as you put it in a sanitized container, you maybe able to keep it clean long enough.
Certainly a risk, but changes are you'll get away with it as long as you are sanitary.