Updated Connection

App now closes connection on app closing and opens the connection again
on app opening