Make messages set me to "offline" when I lock my PC?

Anyone know of a way to get the messages app to put me in "offline" or "unavailable" mode when I lock (CTRL + L) my computer?

It's getting increasingly annoying for both me and people messaging me to think that I'm online when I'm really not.

Thanks :)