Perform pipe close for each Engine.

This removes a file descriptor leak.
The pipe object is protected by a lock to avoid broken pipe
situations.