Be careful not to closewindow() a window during a while(msg=getmsg(...)) loop on that window's port (next getmsg() would be on freed pointer). Also, use modifyidcmp(null) with care, especially if using one port with multiple windows. Be sure to clearmenustrip() any menus before closing a window, and do not free items such as dynamically allocated gadgets and menus while they are attached to a window. Do not reference an intuimessage's iaddress field as a structure pointer of any kind before determining it is a structure pointer (this depends on the class of the IntuiMessage). If a crash or problem only occurs when opening a window after extended use of your program, check to make sure that your program is properly freeing up signals allocated indirectly by createport(), openwindow() or modifyidcmp().