Added locking to vterm_list.
Added checks/fallbacks for non-existent terminal id.
Closing first terminal no longer causes crash.