This kernel module solves problem with laptop turning off after closing the lid.
Tested and works on:
Just run:
make
sudo make install-dkms sudo reboot
sudo make uninstall-dkms sudo reboot