Start > type Power Options > click Power Options > click Change when the computer sleeps > click Change advanced power settings.
You'll want to set all the following categories & their sub categories to "Never" :
Since your trying keep the laptop from turning off, and your using it on your bed, remember not to block the fan by setting it on a soft surface (like a pillow, blanket or mattress). Otherwise, you'll be suffocating it until it overheats.
I just use an old hard cover book to set the laptop on while it's being used in the bed.