Crash when dropping from notebook outside the application window

There is a crash (due to NULL dereference) if dragging out of a notebook and dropping outside the application window. This modifies the code to fix the crash.