When you say:
Is there a way to turn the LCD off via code or do i need a hardware switch?
Are you meaning a way to turn off the pixels?
If so the answer is yes:
Will turn off the pixels. And
will turn the pixels back on.
Now I must warn you about using the D10 backlight control.
There is a design flaw in many of the lcd keypad shields out there that can damage the AVR chip
when using the D10 backlight control.
Read about it in this thread I wrote:http://arduino.cc/forum/index.php/topic,96747.0.html
The thread outlines the problem as well as both a hardware and software work around.
But be careful and avoid using the backlight control until you verify that either your
keypad shield does not have the issue or that you have done a proper work around.
See the above thread for how to see if you board has the issue as simply being able
to control the backlight with d10 does not indicate that there is no an issue.