Fix #1555 : API sessions remain open