Fix #1555 : API sessions remains open