Suspend/resume/close/state.  Fixes #317 and #361