Prisoner took his own life after terror order had 'substantial impact' on mental state, inquest finds