This prevents a segfault when shutting down during startup, when a
client is passed that doesn't spawn a window.
It also brings us one step closer to not having to have a pointer to the
backend in cg_server.
This is based on code from Sway, which is also MIT licensed hence
compatible. This makes the surface damaging and rendering code easier to
follow and makes it easier to import future changes to Sway as well.