wrapped onCloseConnection with try/catch