Lid Closed Suspend then Hibernate
To start using this function you need to create a file /etc/systemd/sleep.conf with the next content:
[Sleep]
HibernateDelaySec=3600
Then you can test it by command:
sudo systemctl suspend-then-hibernate
(you can edit HibernateDelaySec to reduce delay to hibernate). If all works fine you can change Lid Close Action, to do it you need to edit the file /etc/systemd/logind.conf
You need to find option HandleLidSwitch=, uncomment it and change to HandleLidSwitch=suspend-then-hibernate. Then you need to restart logind service(wirning! you user session will be restarted) by the next command:
systemctl restart systemd-logind.service
Thats all! Now you can use this nice function.