Added close() and close test.
Added errors for emit after a close().