fix buffer closing and add tab switch mappings