add idle timeout code; close connection when last NP finishes