Add nil check for comint hook