Correctly handle terminal upon suspend/resotre + handle "bg"