Theoretically it should work, as you're stating your intent to leave. In practice, employers will try and call your bluff.