You can bind a login or logoff script to the NSX Edge gateway.