Running matplotlib within a Cocoa application

Dear all

Has anyone attempted to use matplotlib within a mac (cocoa) application before (e.g. using PyRun_SimpleFile or PyRun_SimpleString)? I can successfully get get a plot to appear in a new window but when closing this window the entire application quits without any error. Looking at the source code, the macosx backend seems to kill the currently running NSApp. Is there a reason for this and is there any way around it?

Many thanks!