Added locking for terminal driver.