check for the driver being null before stopping it

a NPE was being thrown from here prior to this change.