Will Prey work if my laptop is closed or asleep?

No, during that time it won't since Prey runs as a normal process. When your laptop's lid is closed, your Operating System normally "stops" programs from running -- it goes into suspended state.

Some OS's allow you to change this behaviour by modifying the power management preferences -- i.e. you can prevent your system from going into suspended state when the lid is closed.