You can download
pipe, launch it (or use
launcher which shows current status of BF4). Launch BF4 multiplayer again. You should see your error message in it when BF4 closes unexpectedly.
Here are most of the BF4 pipe error codes.
5 1 -1 -> There is a problem with BF4 х64 bit version, you have to use x86.
3 1 -1 -> There is a problem with license file, delete C:\ProgramData\Electronic Arts (hidden folder).
0 3 -1 -> You don't have necessary DLC's to play on this server, download them.
0 4 -> You were kicked out by a game admin.
0 5 -> You have been banned from this server.
0 6 -1 -> You were disconnected from Master!
0 14 -> Your connection to the server timed out.
0 20 -1 -> You were kicked for inactivity.
0 22 -1 -> You were kicked with reason. If there is no reason specified, then you are kicked from game for exceeding teamkill limit.
0 23 -> You were kicked by an admin.
0 24 -1 -> You were kicked by PunkBuster.
0 38 -> You were kicked by FairFight.
1 1 -1 -> Game files are corrupted. Repair them on ZLOrigin.
4 12 -> You are banned on the server.
27 0 -> Please install the official origin, then reinstall ZLOrigin.
3 16 -1 -> ZLOrigin error! Please start the game in 32bit mode (x86).
0 7 -1 -> Server has password.