ends sessions properly