When a caller calls close while you are in the failed state, currently you set the closed flag also.  This is a bit dangerous since you two "end-state" flags.