MSPs have rejected a bid to restrict access to assisted dying to terminally ill Scots expected to live six months or less.