added a quit phase and hooks  to backend