Use the proper way for closing a pipe