fixes #202

fixes #202. added unbeforeunload event handler that checks for dirty state.