add state handling and terminate to http handler behavior