Added a timeout mechanism for operations, like close() that can hang indefinitely.