Yeah, that sometimes happens during REM (or, rapid eye movement).

Try wearing a sleep mask, because it can help to keep your eyes closed. Also make sure that your room is as dark as possible, so even if your eyes do open, you won't snap out of SP from the light.