Gunman tries to kill ex-girlfriend, takes own life