Add missing include and proper close call for linux.