Gracefully stopping containers on server's shutdown

I have an issue with a Windows VM inside a container not shutting down properly when LXC-server shuts down/reboots.
I set up libvirt to turn off guests when the container stops and it works OK when I use lxc-stop, it always waits for the VM to shut down.
But when I reboot LXC-server, the behaviour is completely random: sometimes Windows turns off properly but sometimes it says the shutdown was unexpected on the next boot.
I also enabled “lxc” service on the LXC-server, as far as I understand it’s used to auto start containers but I don’t know if it helps with stopping them properly.
Is there a way to make LXC-server to always wait for the containers to stop before shutting down?