One of mine does this too. I knitted a little blanket for her, and when her lights go off, I wait for her to scratch (normally about 2 minutes later!) and then put the blanket over her, then she'll fidget about a little to get comfy, and settle down. If I don't put the blanket in she will eventually sleep, but it'll take her a while longer of scratching to realise she can't dig under the corner of the viv to get snuggled inside something and give up.
I dunno why she does it, it's not like it's bright in there, I have a curtain which shuts almost all the light from the room out, and if she really wants pitch black she can go inside the hide...I think the scratching has just become part of her routine now. If she's out on my lap at bedtime she does a similar thing, she digs right into her blanket, then turns around 180 degrees, then goes to sleep.