added close and closeSync methods